/* try-on.css */

/* Try-On Specific Layout */
.tryon-layout {
    display: grid;
    margin-top: 64px;
    /* 2 panels on desktop (Inputs + Single Output) */
    grid-template-columns: 280px 1fr;
    gap: 24px;
    padding: 24px 32px 0 32px;
    height: calc(100vh - 64px);
    min-height: 0;
    background: radial-gradient(circle at 10% 10%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 90% 90%, rgba(16, 185, 129, 0.03) 0%, transparent 50%);
}

/* LEFT PANEL */
.tryon-panel-left {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
    overflow-y: auto;
    /* hide scrollbar */
    scrollbar-width: none;
}

.tryon-panel-left::-webkit-scrollbar {
    display: none;
}

.tryon-top-reset-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-white);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    margin-right: 10px;
}

.tryon-top-reset-btn:hover {
    border-color: var(--glass-border-strong);
    background: rgba(255, 255, 255, 0.1);
}

/* On desktop, the wrapper shouldn't interfere with flex children of the left panel */
.tryon-card-wrap {
    display: contents;
}

.tryon-card-label {
    display: none;
    /* Text is a mobile/touch requirement only, hidden on desktop to preserve original layout */
}

.tryon-card {
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 16px;
    background: rgba(16, 185, 129, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tryon-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: opacity 0.3s ease;
}

.tryon-card:hover {
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.05);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.15), inset 0 0 15px rgba(16, 185, 129, 0.05);
    transform: translateY(-2px);
}

.tryon-card:hover::before {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.8), transparent 80%);
}

/* Card Proportions - Equal size */
#card-body,
#card-tattoo {
    flex: 1;
    min-height: 220px;
}

.tryon-card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 2;
}

.tryon-card-title {
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
}

.tryon-card-subtitle {
    color: var(--text-color);
    font-size: 1.1rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    line-height: 1.4;
    font-weight: 500;
}

.tryon-icon-icons {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.tryon-card:hover .tryon-icon-icons {
    opacity: 1;
}

.tryon-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    /* Give it a little breathing room in the card */
}

/* Image Card Overlays - Allow native right-click on image without blocking buttons */
.tryon-card-content,
.tryon-card-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
    pointer-events: none;
}

.tryon-card-controls > *,
.tryon-card-content > * {
    pointer-events: auto;
}

.tryon-card-btn {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tryon-card-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.tryon-card-btn.delete:hover {
    color: #ff4d4d;
    border-color: #ff4d4d;
}

/* Apply Area */
.tryon-apply-area {
    margin-top: auto;
    position: relative;
}

.tryon-apply-btn {
    width: 100%;
    min-height: 40px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    letter-spacing: 1px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* Set color logic according to the reference site buttons */
    background: var(--neon-green);
    color: var(--deep-black);
    border: none;
}

.tryon-apply-btn:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.tryon-apply-btn:disabled,
.tryon-apply-btn.disabled {
    background: var(--surface-light);
    color: rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.tryon-credits-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 12px;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

/* Hidden on desktop — shown only on phone / tablet (see mobile block below) */
.tryon-credits-mobile {
    display: none;
}

/* CENTER/RIGHT PANEL (Workspace/Output) */
.tryon-panel-center {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.tryon-center-workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1%;
    box-sizing: border-box;
    overflow: hidden;
    touch-action: none;
}

@media (pointer: coarse) {
    .tryon-center-workspace {
        contain: layout paint style;
        isolation: isolate;
    }
}

.tryon-center-img,
#center-preview-img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center center;
    flex: 0 1 auto;
    align-self: center;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: zoom-in;
    touch-action: none;
}

@media (min-width: 1024px) {

    .tryon-panel-right,
    .tryon-center-workspace {
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #center-preview-img,
    .tryon-center-img {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        object-position: center center;
        border-radius: 4px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        background: transparent;
        padding: 0;
        cursor: zoom-in;
    }
}

/* Desktop-only visual polish: keep layout, modernize surfaces */
@media (min-width: 1025px) {
    .tryon-layout {
        background:
            radial-gradient(1200px 520px at 72% 44%, rgba(16, 185, 129, 0.06) 0%, rgba(16, 185, 129, 0.02) 38%, transparent 72%),
            radial-gradient(760px 320px at 18% 78%, rgba(16, 185, 129, 0.045) 0%, transparent 70%),
            linear-gradient(180deg, rgba(3, 13, 21, 0.72), rgba(3, 13, 21, 0.32));
    }

    .tryon-panel-left {
        border: none;
        border-radius: 20px;
        padding: 14px;
        background: linear-gradient(180deg, rgba(8, 20, 30, 0.18), rgba(7, 16, 24, 0.08));
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
    }

    .tryon-card {
        border: 1px solid rgba(16, 185, 129, 0.2);
        border-radius: 18px;
        background: linear-gradient(180deg, rgba(8, 22, 28, 0.44), rgba(7, 16, 22, 0.3));
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.035),
            inset 0 -18px 26px rgba(0, 0, 0, 0.22),
            0 8px 24px rgba(0, 0, 0, 0.28);
    }

    .tryon-card:hover {
        border-color: rgba(16, 185, 129, 0.34);
        background: linear-gradient(180deg, rgba(10, 26, 34, 0.56), rgba(7, 18, 24, 0.36));
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.045),
            inset 0 -20px 30px rgba(0, 0, 0, 0.25),
            0 12px 32px rgba(0, 0, 0, 0.34),
            0 0 26px rgba(16, 185, 129, 0.1);
        transform: translateY(-1px);
    }

    .tryon-card-img {
        border-radius: 18px;
    }

    .tryon-panel-right {
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .tryon-center-workspace {
        background: transparent !important;
        box-shadow: none !important;
    }

    .tryon-output-placeholder {
        color: rgba(233, 244, 250, 0.48);
        letter-spacing: 1.6px;
        font-size: 0.82rem;
        text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    }

    .tryon-apply-btn {
        border-radius: 999px;
        box-shadow:
            0 10px 24px rgba(16, 185, 129, 0.23),
            inset 0 1px 0 rgba(255, 255, 255, 0.35);
    }

    .tryon-apply-btn:hover:not(:disabled) {
        box-shadow:
            0 14px 30px rgba(16, 185, 129, 0.28),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

.hidden-force {
    display: none !important;
}

.tryon-center-img:hover {
    transform: scale(1.01);
}

/* RIGHT PANEL (Output) */
.tryon-panel-right {
    background: var(--surface-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    /* Mimic the sketch/generator center panel boundary */
    border: none;
    transition: all 0.3s ease;
}

.tryon-panel-right.active-glow {
    border: 1px solid rgba(16, 185, 129, 0.8);
    box-shadow: inset 0 0 40px rgba(16, 185, 129, 0.1), 0 0 30px rgba(16, 185, 129, 0.1);
}

.tryon-output-placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-family: 'Unbounded', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-align: center;
    padding: 30px;
    text-transform: uppercase;
}

/* APPLYING (top) + GPU tip (below) — absolute overlay so result canvas stays centered */
.tryon-generating-stack {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: auto;
    max-width: none;
    margin: 0;
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

.tryon-generating-stack #output-placeholder {
    margin: 0;
    padding-bottom: 8px;
}

.tryon-generating-stack #tg-tryon-wait-status {
    margin: 0;
    width: min(320px, 92%);
    max-width: 320px;
    text-transform: none;
    letter-spacing: 0.02em;
}

/* Local History Strip (Top Navbar) */
.tryon-recents-strip {
    display: flex;
    gap: 12px;
    margin: 0 24px;
}

.tryon-recent-slot {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(16, 185, 129, 0.5);
    border-radius: 6px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.tryon-recent-slot.empty {
    border: 1px dashed rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.03);
}

.tryon-recent-slot:not(.empty):hover {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* MARKING MODAL */
.tryon-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: visible;
}

@media (max-width: 1024px) {
    .tryon-modal-overlay {
        overflow: visible;
    }
}

.tryon-modal-content {
    background: var(--surface-dark);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    width: 90vw;
    max-width: 600px;
    height: 90vh;
    max-height: 950px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 40px rgba(16, 185, 129, 0.05);
    overflow: hidden;
    position: relative;
}

.tryon-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}

.tryon-modal-header h3 {
    margin: 0 0 6px 0;
    color: var(--text-color);
    font-family: 'Unbounded', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.tryon-modal-header p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.tryon-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.2);
    color: #ff4d4d;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s ease;
    line-height: 1;
    padding-bottom: 2px;
}

.tryon-modal-close:hover {
    background: rgba(255, 77, 77, 0.2);
    border-color: #ff4d4d;
    transform: scale(1.1);
}

.tryon-modal-notice {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(15, 18, 25, 0.95);
    border: 1px solid var(--neon-purple);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10002;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(34, 197, 94, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    max-width: 80%;
    width: max-content;
}

.tryon-modal-notice.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tryon-modal-canvas-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
    min-width: 320px;
    min-height: 320px;
    background: #000;
}

#marking-canvas-bg,
#marking-canvas-draw {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: crosshair;
}

.tryon-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.tryon-modal-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tryon-tool-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tryon-tool-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.tryon-tool-btn.active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.tryon-tool-btn svg {
    opacity: 0.8;
}

.tryon-tool-btn:hover svg,
.tryon-tool-btn.active svg {
    opacity: 1;
}

/* Mobile Portrait specific hover override to prevent sticky active visual states */
@media (max-width: 600px) {
    /* Phone-only: give maximum vertical room to the generated result */

    /* Shrink bottom cards strip to free space for output panel */
    #card-body,
    #card-tattoo {
        min-height: 100px !important;
        height: auto !important;
    }

    /* Output panel: fill more space, remove border radius so image goes edge-to-edge */
    .tryon-panel-right {
        border-radius: 20px !important;
        padding: 4px !important;
    }

    /* Workspace fills the panel */
    .tryon-center-workspace {
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    /* Image: fill workspace without stretching aspect ratio */
    #center-preview-img,
    .tryon-center-img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        object-position: center center !important;
    }

    /* Shrink gap between cards */
    .tryon-panel-left {
        gap: 6px !important;
    }

    .tryon-tool-btn:hover:not(.active) {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: var(--text-color);
    }

    .tryon-tool-btn:hover:not(.active) svg {
        opacity: 0.8;
    }
}

/* iPad specific hover override to prevent sticky active visual states */
@media (min-width: 601px) and (max-width: 1366px) {
    @media (hover: none) and (pointer: coarse) {
        .tryon-tool-btn:hover:not(.active) {
            background: rgba(255, 255, 255, 0.05);
            border-color: rgba(255, 255, 255, 0.1);
            color: var(--text-color);
        }

        .tryon-tool-btn:hover:not(.active) svg {
            opacity: 0.8;
        }
    }
}

/* --- RESULT STRIP / HISTORY (In Top Header) --- */
.tryon-result-history {
    display: flex;
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    gap: 8px;
    margin: 0 12px;
    overflow: hidden;
    align-items: center;
}

.tryon-output-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.4);
    cursor: pointer;
    background: rgba(16, 185, 129, 0.05);
    object-fit: cover;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.tryon-output-thumbnail:hover,
.tryon-output-thumbnail.active {
    opacity: 1;
    border-color: var(--neon-green);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

/* Phone header thumbnail cap → css/phone-header-recents-lock.css (do not duplicate here). */

.tryon-output-thumbnail:hover,
.tryon-output-thumbnail.active {
    border-color: rgba(16, 185, 129, 0.9);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    transform: translateY(-2px);
}

.tryon-output-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

/* Desktop only: place generated-image download at top-right and theme-match green UI */
@media (min-width: 1025px) {
    .tryon-output-actions {
        top: 12px;
        right: 12px;
        bottom: auto;
    }

    .tryon-output-actions #btn-out-download {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        border: 1px solid rgba(16, 185, 129, 0.36);
        background: linear-gradient(180deg, rgba(10, 24, 28, 0.96), rgba(7, 18, 22, 0.96));
        color: #dffef2;
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.10),
            0 10px 24px rgba(0, 0, 0, 0.34),
            0 0 24px rgba(16, 185, 129, 0.16);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .tryon-output-actions #btn-out-download:hover {
        transform: translateY(-1px);
        border-color: rgba(16, 185, 129, 0.55);
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.14),
            0 14px 28px rgba(0, 0, 0, 0.42),
            0 0 28px rgba(16, 185, 129, 0.22);
    }
}

.tryon-output-download-mobile {
    display: none;
}

/* --- UPLOAD CHOOSER ACTION SHEET --- */
.tryon-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    z-index: 9998;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 16px 24px;
    animation: sheetFadeIn 0.2s ease;
}

@keyframes sheetFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.tryon-sheet-content {
    background: var(--surface-dark, #0f1219);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 16px;
    width: 100%;
    max-width: 360px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    animation: sheetSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetSlide {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

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

.tryon-sheet-title {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tryon-sheet-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tryon-sheet-option:active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--neon-green);
}

.tryon-sheet-cancel {
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 4px;
}

.tryon-sheet-cancel:active {
    color: #fff;
}

/* --- MOBILE SPECIFIC LAYOUT --- */
.tryon-mobile-apply-wrap {
    display: none;
}

@media (max-width: 1100px) {
    .tryon-layout {
        display: flex;
        flex-direction: column;
        padding: 12px;
        margin-top: 64px;
        height: calc(100dvh - 64px);
        height: calc(100vh - 64px);
        /* fallback */
        gap: 10px;
        position: relative;
        overflow: hidden;
    }

    /* Support dvh where available */
    @supports (height: 100dvh) {
        .tryon-layout {
            height: calc(100dvh - 64px);
        }
    }

    .tryon-panel-right {
        order: -1;
        width: 100%;
        flex: 1 1 auto;
        min-height: 120px;
        border-radius: 16px;
    }

    .tryon-panel-left {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        height: auto;
        flex-shrink: 0;
        gap: 12px;
        padding-bottom: 0;
        overflow: visible;
        justify-content: center;
        align-items: center;
    }

    .tryon-credits-mobile {
        display: block;
        width: 100%;
        flex: 0 0 100%;
        order: 10;
        text-align: center;
        font-size: 10px;
        line-height: 1.3;
        color: var(--text-dim);
        padding: 2px 8px 4px;
        margin: 0;
        letter-spacing: 0.2px;
    }

    .tryon-card-wrap {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .tryon-card-label {
        font-size: 0.65rem;
        margin-bottom: 0;
        display: block;
        text-align: center;
        color: var(--text-color);
        font-weight: 500;
        letter-spacing: 0.5px;
    }

    .tryon-card {
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 16px;
        background: rgba(16, 185, 129, 0.04);
        border: 1px solid rgba(16, 185, 129, 0.2);
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.06),
            inset 0 0 20px rgba(16, 185, 129, 0.04),
            0 4px 16px rgba(0, 0, 0, 0.5);
        transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
        position: relative;
        overflow: hidden;
    }

    .tryon-card::before {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 16px;
        padding: 1px;
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.5), rgba(16, 185, 129, 0.1) 50%, rgba(16, 185, 129, 0.05) 100%);
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        pointer-events: none;
    }

    .tryon-card:active {
        transform: scale(0.97);
        background: rgba(16, 185, 129, 0.08);
        box-shadow:
            0 0 0 1px rgba(16, 185, 129, 0.15),
            inset 0 0 25px rgba(16, 185, 129, 0.08),
            0 2px 8px rgba(0, 0, 0, 0.4);
    }

    #body-content-empty,
    #tattoo-content-empty {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        box-sizing: border-box;
        width: 100%;
        height: 100%;
        padding: 8px 8px;
        margin: 0;
        gap: 5px;
        right: auto;
        bottom: auto;
        z-index: 2;
        pointer-events: none;
    }

    #body-content-empty .tryon-card-title,
    #body-content-empty .tryon-card-subtitle,
    #body-content-empty .tryon-icon-icons,
    #tattoo-content-empty .tryon-card-title,
    #tattoo-content-empty .tryon-card-subtitle,
    #tattoo-content-empty .tryon-icon-icons {
        width: 100%;
        text-align: center;
        align-self: center;
        margin-left: auto;
        margin-right: auto;
    }

    .tryon-icon-icons {
        margin-bottom: 2px;
        gap: 8px;
        filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4));
        transition: filter 0.25s ease;
    }

    .tryon-card:active .tryon-icon-icons {
        filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.7));
    }

    .tryon-icon-icons svg {
        width: 22px;
        height: 22px;
        opacity: 0.9;
    }

    .tryon-card-title {
        font-family: 'Unbounded', sans-serif;
        font-size: 0.58rem;
        letter-spacing: 0.8px;
        color: rgba(16, 185, 129, 0.7);
        text-transform: uppercase;
        text-align: center;
        font-weight: 600;
    }

    .tryon-card-subtitle {
        display: block;
        font-size: 0.6rem;
        font-family: 'Plus Jakarta Sans', sans-serif;
        line-height: 1.3;
        text-align: center;
        padding: 0 6px;
        color: rgba(255, 255, 255, 0.55);
    }

    /* Target IDs explicitly to override the desktop flex: 1.4 and flex: 1 */
    #card-body,
    #card-tattoo {
        flex: 0 0 108px;
        width: 108px;
        height: 96px;
        min-height: unset;
        max-height: unset;
    }

    .tryon-card-img {
        border-radius: 16px;
        padding: 4px;
        background: transparent;
    }

    .tryon-card-controls {
        bottom: 6px;
        right: 6px;
        gap: 6px;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(8px);
        padding: 4px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .tryon-card-btn {
        width: 24px;
        height: 24px;
        border-radius: 6px;
        background: transparent;
        border: none;
        backdrop-filter: none;
    }

    .tryon-card-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Hide desktop apply area */
    .tryon-apply-area {
        display: none !important;
    }

    /* Mobile Apply Button — inline in row, not absolute */
    .tryon-mobile-apply-wrap {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        position: static;
        flex-shrink: 0;
    }

    /* iPad / tablet: float generate control bottom-right (spinner to the right of button) */
    @media (min-width: 600px) {
        .tryon-mobile-apply-wrap {
            position: absolute;
            bottom: 24px;
            right: 24px;
            z-index: 100;
        }
    }

    .tryon-mobile-apply-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        padding: 0;
        border-radius: 50%;
        background: var(--neon-green) !important;
        color: #020617 !important;
        border: 1px solid var(--neon-green);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
        font-size: 0;
        line-height: 0;
        overflow: hidden;
        flex: 0 0 48px;
    }

    .tryon-mobile-apply-btn svg {
        stroke: #020617;
        filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.35));
        transition: transform 0.2s ease;
    }

    .tryon-mobile-apply-btn.is-generating svg {
        transform: translateX(-4px);
    }

    .tryon-mobile-apply-btn:active:not(:disabled) {
        transform: scale(0.95);
    }

    .tryon-mobile-apply-btn[disabled],
    .tryon-mobile-apply-btn.disabled {
        cursor: not-allowed;
    }

    .tryon-mobile-apply-btn.is-generating {
        opacity: 0.6;
        filter: grayscale(0.4);
    }

    .tryon-phone-spinner {
        width: 22px;
        height: 22px;
        border: 2.5px solid rgba(16, 185, 129, 0.18);
        border-top-color: var(--neon-green);
        border-radius: 50%;
        animation: tryon-phone-spin 0.9s linear infinite;
        flex: 0 0 auto;
        margin-left: 8px;
    }

    @keyframes tryon-phone-spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }

    .tryon-output-thumbnail {
        width: 40px;
        height: 40px;
        border-radius: 6px;
    }

    .tryon-output-placeholder {
        font-size: 0.75rem;
        letter-spacing: 1.5px;
        padding: 20px;
    }

    /* Modal responsive on mobile */
    .tryon-modal-overlay {
        padding: 8px;
    }

    .tryon-modal-content {
        width: 100%;
        max-width: none;
        height: 95vh;
        border-radius: 16px;
    }

    .tryon-modal-header {
        padding: 12px 16px;
    }

    .tryon-modal-header h3 {
        font-size: 0.95rem;
    }

    .tryon-modal-header p {
        font-size: 0.75rem;
    }

    .tryon-modal-canvas-wrap {
        min-width: 0;
        min-height: 0;
    }

    .tryon-modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }

    .tryon-modal-tools {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    #btn-modal-clear {
        margin-right: auto;
    }

    #btn-modal-done {
        margin-left: auto;
    }

    .tryon-tool-btn {
        width: 34px;
        height: 34px;
    }
}

/* --- ENLARGED VIEWER / LIGHTBOX --- */
.tryon-viewer-content {
    width: 95vw;
    height: 95vh;
    max-width: 1200px;
    max-height: 900px;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 50px rgba(16, 185, 129, 0.1);
    animation: viewerAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: visible;
}

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

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

.tryon-viewer-img-wrap {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .tryon-output-actions {
        bottom: 12px;
        right: 12px;
    }

    .tryon-output-actions #btn-out-download {
        display: none;
    }

    .tryon-output-download-mobile {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
        border-radius: 14px;
        border: 1px solid rgba(16, 185, 129, 0.28);
        background: linear-gradient(180deg, rgba(10, 24, 28, 0.96), rgba(7, 18, 22, 0.96));
        color: #dffef2;
        box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.08), 0 10px 24px rgba(0, 0, 0, 0.34), 0 0 22px rgba(16, 185, 129, 0.14);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        align-items: center;
        justify-content: center;
        z-index: 30;
        cursor: pointer;
        transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    }

    .tryon-output-download-mobile:hover,
    .tryon-output-download-mobile:active {
        transform: translateY(-1px);
        border-color: rgba(16, 185, 129, 0.5);
        box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.12), 0 14px 28px rgba(0, 0, 0, 0.42), 0 0 28px rgba(16, 185, 129, 0.2);
    }

    .tryon-output-download-mobile svg {
        width: 18px;
        height: 18px;
        color: var(--neon-green);
    }

    .tryon-viewer-content {
        width: min(96vw, 720px);
        height: auto;
        max-height: 92dvh;
        padding: 16px 16px 12px;
    }

    .tryon-viewer-img-wrap {
        flex: 1 1 auto;
        min-height: 0;
        max-height: calc(92dvh - 140px);
        overflow: hidden;
        margin-bottom: 12px;
    }

    #enlarged-img {
        display: block;
        max-width: 100%;
        max-height: calc(92dvh - 160px);
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 8px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
        transform: none !important;
        -webkit-transform: none !important;
        touch-action: none;
        cursor: default;
    }
}

#enlarged-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.tryon-viewer-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding-top: 8px;
}

.tryon-viewer-actions .btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tryon-viewer-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.tryon-viewer-actions .btn.delete:hover {
    color: #ff4d4d;
    border-color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

.tryon-viewer-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
    margin-bottom: 8px;
}

.tryon-viewer-close {
    position: relative;
    top: auto;
    right: auto;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10002;
    padding: 0;
    flex-shrink: 0;
}

.tryon-viewer-close:hover {
    background: var(--surface-hover);
    color: var(--neon-green);
}

.tryon-viewer-close svg {
    display: block;
    pointer-events: none;
}

/* Desktop only: keep enlarged history image fully contained in viewer */
@media (min-width: 1025px) {
    .tryon-viewer-content {
        width: auto;
        height: auto;
        max-width: min(94vw, 980px);
        max-height: 92vh;
        padding: 18px 18px 16px;
        overflow: visible;
        align-items: center;
    }

    .tryon-viewer-img-wrap {
        flex: none;
        width: auto;
        max-width: min(88vw, 760px);
        max-height: 70vh;
        overflow: hidden;
        margin-bottom: 12px;
        padding: 10px 12px;
    }

    #enlarged-img {
        width: auto;
        height: auto;
        max-width: min(88vw, 740px);
        max-height: calc(70vh - 22px);
        object-fit: contain;
        display: block;
    }

    .tryon-viewer-actions {
        width: auto;
        flex-wrap: wrap;
    }
}

@media (max-width: 900px) {
    .tryon-viewer-content {
        padding: 16px 16px 12px;
        width: min(100vw, 720px);
        height: auto;
        max-height: 100dvh;
        border-radius: 16px;
    }

    .tryon-viewer-img-wrap {
        max-height: calc(100dvh - 160px);
    }

    #enlarged-img {
        max-width: 100%;
        max-height: calc(100dvh - 180px);
    }

    .tryon-viewer-actions {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .tryon-viewer-actions .btn {
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .tryon-viewer-actions .btn span {
        display: inline;
    }
}

@media (max-width: 600px) {
    .tryon-viewer-actions .btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        padding: 10px 8px;
    }

    .tryon-viewer-actions .btn span {
        font-size: 0.75rem;
    }
}

/* Canvas touch behavior - must be outside media query for all touch devices */
#marking-canvas-draw {
    touch-action: none;
}

/* Block browser page pinch on Try-On; preview uses touch-zoom.js (touch-action: none there). */
@media (max-width: 1100px) and (pointer: coarse) {
    html.try-on-page,
    body.try-on-page {
        touch-action: manipulation;
        overflow: hidden;
    }

    body.try-on-page .tryon-layout {
        touch-action: manipulation;
    }

    body.try-on-page #center-workspace,
    body.try-on-page #center-workspace .tryon-center-img {
        touch-action: none;
    }
}

/* Tablet landscape only: keep full content visible in Safari viewport */
@media (orientation: landscape) and (pointer: coarse) and (min-width: 901px) and (max-width: 1366px) {
    .tryon-layout {
        height: calc(100dvh - 64px);
        padding: 16px 20px 8px 20px;
        gap: 14px;
    }

    .tryon-panel-left {
        gap: 14px;
    }

    #card-body,
    #card-tattoo {
        min-height: 188px;
    }

    .tryon-apply-btn {
        min-height: 36px;
        font-size: 0.82rem;
        padding: 7px 14px;
    }

    .tryon-credits-text {
        margin-top: 8px;
        font-size: 0.7rem;
    }
}

/* Try-On phone/tablet: lock header history strip + fix layout (same pattern as Magic Blend). */
@media (max-width: 1024px) and (pointer: coarse) {
    body.try-on-page .main-header {
        overflow: hidden !important;
        contain: layout style !important;
    }

    body.try-on-page .main-header .nav-container {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        overflow: hidden !important;
        min-height: 64px !important;
        max-height: 64px !important;
    }

    body.try-on-page .app-brand-wrap,
    body.try-on-page .nav-actions.app-nav-actions-shrink {
        position: relative !important;
        z-index: 2 !important;
        flex: 0 0 auto !important;
    }

    body.try-on-page #tryon-result-history {
        position: absolute !important;
        left: calc(76px + 2mm) !important;
        right: 96px !important;
        top: 0 !important;
        bottom: 0 !important;
        height: 44px !important;
        max-height: 44px !important;
        margin: auto 0 !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        width: auto !important;
        flex: none !important;
        min-width: 0 !important;
        padding: 0 !important;
        gap: 5px !important;
        justify-content: flex-start !important;
        align-items: center !important;
        overflow: hidden !important;
        transform: none !important;
        box-sizing: border-box !important;
        z-index: 1 !important;
    }

    /* iPad/tablet only: nudge history strip right so TRY-ON brand does not overlap thumbnails */
    @media (min-width: 601px) and (max-width: 1024px) and (pointer: coarse) {
        body.try-on-page #tryon-result-history {
            left: calc(76px + 7mm) !important;
        }
    }

    body.try-on-page .tryon-layout {
        margin-top: 64px;
        height: calc(100dvh - 64px);
        min-height: 0;
        overflow: hidden;
    }

    body.try-on-page .tryon-panel-right {
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }

    body.try-on-page .tryon-panel-left {
        flex: 0 0 auto !important;
        position: relative !important;
    }

    body.try-on-page .tryon-mobile-apply-wrap {
        position: static !important;
    }
}

@media (max-width: 600px) and (pointer: coarse) {
    body.try-on-page .tryon-mobile-apply-wrap {
        position: static !important;
        bottom: auto !important;
        right: auto !important;
    }
}

/* Signed-out privacy: never flash stale upload/output pixels before JS bootstrap completes */
body.try-on-page.tryon-workspace-pending .tryon-card-img,
body.try-on-page.tryon-workspace-pending #center-preview-img,
body.try-on-page.tryon-workspace-pending #center-workspace {
    visibility: hidden !important;
}

/* Header result history is account-scoped — must stay visible during bootstrap */
body.try-on-page.tryon-workspace-pending .main-header .tryon-result-history,
body.try-on-page.tryon-workspace-pending .hdr-editor-title-lane .tryon-result-history {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Refresh during generation: keep cached uploads + header thumbs visible while auth finishes */
body.try-on-page.tryon-workspace-pending.tryon-resume-generating .tryon-card-img,
body.try-on-page.tryon-workspace-pending.tryon-resume-generating .tryon-result-history {
    visibility: visible !important;
}