/* Local background removal workspace */
.local-cutout-tool-card {
    isolation: isolate;
    background: linear-gradient(145deg, rgba(236, 253, 245, .96), rgba(245, 243, 255, .92)) !important;
    border-color: rgba(52, 211, 153, .32) !important;
}

.local-cutout-tool-card::after {
    background:
        radial-gradient(360px 150px at 90% 0%, rgba(52, 211, 153, .21), transparent 60%),
        radial-gradient(250px 130px at 5% 100%, rgba(139, 92, 246, .12), transparent 62%) !important;
}

.local-cutout-free-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border: 1px solid rgba(52, 211, 153, .35);
    border-radius: 999px;
    color: #047857;
    background: rgba(255, 255, 255, .78);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .04em;
    box-shadow: 0 5px 14px rgba(5, 150, 105, .08);
}

.local-bg-panel {
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 28px;
    background:
        radial-gradient(900px 440px at 6% -6%, rgba(196, 181, 253, .24), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, rgba(167, 243, 208, .20), transparent 62%),
        rgba(250, 249, 253, .98);
    box-shadow: 0 38px 110px rgba(30, 24, 42, .32), inset 0 1px 0 rgba(255, 255, 255, .96);
    animation: localBgEnter .24s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes localBgEnter {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.local-bg-header {
    min-height: 74px;
    padding: 14px 18px 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(221, 214, 238, .82);
    background: rgba(255, 255, 255, .70);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.local-bg-brand-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(167, 139, 250, .35);
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(145deg, #8b5cf6, #6d28d9 58%, #4c1d95);
    box-shadow: 0 10px 25px rgba(109, 40, 217, .24), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.local-bg-private-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 21px;
    padding: 0 8px;
    border: 1px solid rgba(52, 211, 153, .28);
    border-radius: 999px;
    color: #047857;
    background: rgba(236, 253, 245, .86);
    font-size: 9px;
    font-weight: 800;
}

.local-bg-close,
.local-bg-mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(221, 214, 238, .9);
    color: #7b708e;
    background: rgba(255, 255, 255, .86);
    transition: color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.local-bg-close {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(41, 34, 56, .07);
}

.local-bg-mini-btn {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 10px;
    font-size: 10px;
}

.local-bg-close:hover,
.local-bg-mini-btn:hover {
    color: #4c1d95;
    border-color: rgba(139, 92, 246, .36);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(76, 29, 149, .10);
}

.local-bg-body {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
}

.local-bg-sidebar {
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    border-right: 1px solid rgba(221, 214, 238, .82);
    background: rgba(248, 246, 252, .76);
}

.local-bg-step-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
}

.local-bg-step-row span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #a098ad;
    font-size: 8px;
    font-weight: 800;
}

.local-bg-step-row span b {
    width: 17px;
    height: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #8e849e;
    background: #ebe7f3;
    font-size: 8px;
}

.local-bg-step-row span.is-active { color: #5b21b6; }
.local-bg-step-row span.is-active b { color: white; background: #7c3aed; }
.local-bg-step-row i { height: 1px; flex: 1; background: #e1dbe9; }

.local-bg-drop-zone {
    position: relative;
    width: 100%;
    min-height: 254px;
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px dashed rgba(139, 92, 246, .43);
    border-radius: 22px;
    background:
        radial-gradient(260px 130px at 50% 0%, rgba(196, 181, 253, .18), transparent 65%),
        rgba(255, 255, 255, .76);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .96), 0 15px 35px rgba(62, 48, 92, .05);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.local-bg-drop-zone::before,
.local-bg-drop-zone::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.local-bg-drop-zone::before {
    width: 130px;
    height: 130px;
    left: -72px;
    bottom: -80px;
    background: rgba(167, 243, 208, .18);
}

.local-bg-drop-zone::after {
    width: 90px;
    height: 90px;
    right: -50px;
    top: -42px;
    background: rgba(216, 180, 254, .20);
}

.local-bg-drop-zone:hover,
.local-bg-drop-zone.is-dragging {
    transform: translateY(-2px);
    border-color: rgba(109, 40, 217, .72);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 18px 42px rgba(76, 29, 149, .11);
}

.local-bg-upload-orbit {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(196, 181, 253, .76);
    border-radius: 18px;
    color: #6d28d9;
    background: linear-gradient(145deg, #fff, #f4f0ff);
    font-size: 20px;
    box-shadow: 0 13px 28px rgba(109, 40, 217, .12), inset 0 1px 0 rgba(255, 255, 255, .95);
}

.local-bg-upload-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 999px;
    color: white;
    background: #17131f;
    font-weight: 800;
    box-shadow: 0 12px 25px rgba(23, 19, 31, .18);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.local-bg-upload-cta {
    min-height: 32px;
    margin-top: 17px;
    padding: 0 14px;
    font-size: 9px;
}

.local-bg-upload-cta:hover { transform: translateY(-1px); background: #2b2437; box-shadow: 0 15px 30px rgba(23, 19, 31, .22); }

.local-bg-file-card,
.local-bg-progress-card,
.local-bg-control-card,
.local-bg-info-card {
    border: 1px solid rgba(221, 214, 238, .86);
    border-radius: 16px;
    background: rgba(255, 255, 255, .80);
    box-shadow: 0 10px 26px rgba(43, 34, 62, .04);
}

.local-bg-file-card {
    min-height: 66px;
    padding: 9px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.local-bg-file-thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 11px;
    background: #eeeaf5;
}

.local-bg-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.local-bg-file-actions { display: flex; flex: 0 0 auto; gap: 5px; }
.local-bg-mini-btn.is-delete { color: #a54b62; }
.local-bg-mini-btn.is-delete:hover {
    color: #be123c;
    border-color: rgba(244, 63, 94, .30);
    background: rgba(255, 241, 242, .94);
    box-shadow: 0 10px 24px rgba(190, 18, 60, .10);
}
.local-bg-mini-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.local-bg-progress-card { margin-top: 10px; padding: 12px; }
.local-bg-control-card { padding: 12px; }

.local-bg-progress-track {
    height: 6px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece8f3;
}

.local-bg-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8b5cf6, #6d28d9, #10b981);
    box-shadow: 0 0 12px rgba(124, 58, 237, .28);
    transition: width .2s ease;
}

.local-bg-value-chip,
.local-bg-ready-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 999px;
    font-size: 8px;
    font-weight: 900;
}

.local-bg-value-chip { min-height: 20px; padding: 0 8px; color: #6d28d9; background: #f1ecff; }
.local-bg-ready-badge { min-height: 23px; padding: 0 9px; color: #047857; background: #ecfdf5; border: 1px solid rgba(52, 211, 153, .28); }

.local-bg-range {
    width: 100%;
    height: 4px;
    border: none;
    border-radius: 999px;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #8b5cf6 var(--range-progress, 0%), #e8e3ef var(--range-progress, 0%));
    cursor: pointer;
}

.local-bg-range::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    appearance: none;
    -webkit-appearance: none;
    border: 3px solid white;
    border-radius: 50%;
    background: #6d28d9;
    box-shadow: 0 3px 10px rgba(76, 29, 149, .30);
}

.local-bg-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 3px solid white;
    border-radius: 50%;
    background: #6d28d9;
    box-shadow: 0 3px 10px rgba(76, 29, 149, .30);
}

.local-bg-background-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
}

.local-bg-background-options button {
    min-width: 0;
    min-height: 46px;
    padding: 5px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #8c8399;
    font-size: 8px;
    font-weight: 800;
    transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.local-bg-background-options button:hover,
.local-bg-background-options button.is-active { color: #5b21b6; border-color: rgba(139, 92, 246, .24); background: #f7f4ff; }

.local-bg-background-options button span {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(105, 94, 122, .18);
    border-radius: 6px;
}

.local-bg-background-options .is-checker,
.local-bg-preview-stage.is-transparent {
    background-color: #f5f2f8;
    background-image:
        linear-gradient(45deg, #ded8e7 25%, transparent 25%),
        linear-gradient(-45deg, #ded8e7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ded8e7 75%),
        linear-gradient(-45deg, transparent 75%, #ded8e7 75%);
}

.local-bg-background-options .is-checker { background-size: 8px 8px; background-position: 0 0, 0 4px, 4px -4px, -4px 0; }
.local-bg-background-options .is-white { background: #fff; }
.local-bg-background-options .is-black { background: #17131f; }
.local-bg-background-options .is-purple { background: #6d28d9; }

.local-bg-info-card {
    padding: 11px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: #82788f;
    background: linear-gradient(145deg, rgba(236, 253, 245, .82), rgba(255, 255, 255, .78));
    font-size: 8.5px;
    line-height: 1.55;
}

.local-bg-info-card strong { color: #246c56; font-size: 9px; }
.local-bg-info-icon { width: 26px; height: 26px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 9px; color: #059669; background: white; }

.local-bg-workspace {
    min-width: 0;
    min-height: 0;
    padding: 18px 20px 16px;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, .45);
}

.local-bg-preview-toolbar,
.local-bg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.local-bg-preview-toolbar { min-height: 35px; margin-bottom: 10px; }

.local-bg-preview-stage {
    position: relative;
    min-height: 0;
    flex: 1;
    overflow: hidden;
    border: 1px solid rgba(206, 198, 219, .86);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 18px 46px rgba(46, 35, 65, .08);
    transition: background .2s ease;
}

.local-bg-preview-stage.is-transparent { background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.local-bg-preview-stage.is-white { background: #fff; }
.local-bg-preview-stage.is-black { background: #17131f; }
.local-bg-preview-stage.is-purple { background: linear-gradient(145deg, #7c3aed, #4c1d95); }

.local-bg-empty-state,
.local-bg-processing-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.local-bg-empty-state { background: rgba(250, 248, 253, .58); }
.local-bg-processing-overlay { background: rgba(251, 249, 254, .78); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.local-bg-empty-art {
    position: relative;
    width: 104px;
    height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(196, 181, 253, .52);
    border-radius: 30px;
    background: linear-gradient(145deg, rgba(255, 255, 255, .95), rgba(243, 240, 252, .94));
    box-shadow: 0 22px 50px rgba(91, 70, 148, .12), inset 0 1px 0 rgba(255, 255, 255, .96);
}

.local-bg-empty-art::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 22px;
    background-image:
        linear-gradient(45deg, #ebe6f1 25%, transparent 25%),
        linear-gradient(-45deg, #ebe6f1 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ebe6f1 75%),
        linear-gradient(-45deg, transparent 75%, #ebe6f1 75%);
    background-size: 14px 14px;
    background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

.local-bg-empty-art .is-subject {
    position: relative;
    z-index: 1;
    width: 52px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px 24px 18px 18px;
    color: white;
    background: linear-gradient(160deg, #a78bfa, #6d28d9);
    font-size: 28px;
    box-shadow: 0 12px 26px rgba(109, 40, 217, .22);
}

.local-bg-image-stage { position: absolute; inset: 0; }
.local-bg-preview-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.local-bg-result-image { clip-path: inset(0 0 0 0); }

.local-bg-compare-line {
    position: absolute;
    z-index: 3;
    top: 0;
    bottom: 0;
    left: 100%;
    width: 1px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 1px rgba(32, 24, 44, .14), 0 0 18px rgba(32, 24, 44, .22);
    transform: translateX(-1px);
}

.local-bg-compare-line span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    background: #17131f;
    font-size: 9px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .24);
    transform: translate(-50%, -50%);
}

.local-bg-processing-orb {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    background: linear-gradient(145deg, #8b5cf6, #5b21b6);
    font-size: 19px;
    box-shadow: 0 18px 38px rgba(91, 33, 182, .25);
}

.local-bg-processing-orb span {
    position: absolute;
    inset: -8px;
    border: 2px solid transparent;
    border-top-color: #8b5cf6;
    border-right-color: #34d399;
    border-radius: 50%;
    animation: localBgSpin 1s linear infinite;
}

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

.local-bg-compare-control {
    min-height: 42px;
    padding: 0 4px;
    display: grid;
    grid-template-columns: auto minmax(100px, 280px) auto;
    align-items: center;
    justify-content: center;
    gap: 11px;
    color: #83798f;
    font-size: 8px;
    font-weight: 800;
}

.local-bg-compare-control .local-bg-range { --range-progress: 100%; }

.local-bg-footer {
    min-height: 58px;
    padding-top: 12px;
    border-top: 1px solid rgba(221, 214, 238, .76);
}

.local-bg-download-button {
    min-width: 186px;
    min-height: 42px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 13px;
    color: white;
    background: linear-gradient(135deg, #17131f, #2d2539);
    font-size: 11px;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(23, 19, 31, .20);
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.local-bg-download-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(23, 19, 31, .25); }
.local-bg-download-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

@media (max-width: 900px) {
    .local-bg-body { grid-template-columns: 260px minmax(0, 1fr); }
    .local-bg-sidebar { padding: 14px; }
    .local-bg-workspace { padding: 14px; }
    .local-bg-drop-zone { min-height: 220px; }
}

@media (max-width: 700px) {
    #localBgModal { overflow-y: auto; }
    .local-bg-panel { height: auto !important; min-height: calc(100vh - 24px); border-radius: 22px; }
    .local-bg-header { min-height: 64px; padding: 11px 12px; }
    .local-bg-brand-icon { width: 36px; height: 36px; border-radius: 12px; }
    .local-bg-private-pill { display: none; }
    .local-bg-body { display: flex; flex-direction: column; }
    .local-bg-sidebar { overflow: visible; border-right: none; border-bottom: 1px solid rgba(221, 214, 238, .82); }
    .local-bg-step-row { display: none; }
    .local-bg-drop-zone { min-height: 184px; }
    .local-bg-workspace { min-height: 590px; }
    .local-bg-preview-stage { min-height: 420px; }
    .local-bg-footer { align-items: stretch; flex-direction: column; }
    .local-bg-download-button { width: 100%; }
}

@media (max-width: 420px) {
    .local-bg-workspace { min-height: 520px; }
    .local-bg-preview-stage { min-height: 350px; }
    .local-bg-empty-art { width: 92px; height: 92px; border-radius: 27px; }
    .local-bg-empty-art .is-subject { width: 46px; height: 60px; font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
    .local-bg-panel,
    .local-bg-processing-orb span { animation: none !important; }
}
