/* ════════════════════════════════════════════════════
   DanteImageTools v7 — Clean Light Mode

   Design: Vercel-inspired clean white UI
   Base: Pure white #ffffff
   Surface: Soft gray #f9fafb
   Accent: Violet #7c3aed with soft glows
   Font: Nunito (rounded, warm)
   Mobile: Bottom-sheet pattern for settings
   ════════════════════════════════════════════════════ */

:root {
    --bg: #ffffff;
    --bg-surface: #f9fafb;
    --bg-hover: #f3f4f6;
    --bg-active: #ede9fe;

    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --border-accent: #c4b5fd;

    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: #ede9fe;
    --accent-glow: rgba(124, 58, 237, 0.15);
    --accent-glow-strong: rgba(124, 58, 237, 0.25);
    --accent-bright: #a78bfa;
    /* Gradient diagonal violeta: claro → escuro */
    --accent-gradient: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
    --accent-gradient-hover: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-accent: 0 4px 14px var(--accent-glow);
}

*, *::before, *::after { box-sizing: border-box; }
body { background: var(--bg); }

/* ── Brand wordmark ─────────────────────────────────── */
.brand-wordmark { align-items: baseline; gap: 6px; line-height: 1; }
.brand-prefix {
    font-family: 'Poppins', system-ui, sans-serif;
    font-weight: 900;
    font-size: 15px;
    letter-spacing: 0.04em;
    color: var(--text);
    text-transform: uppercase;
}
.brand-suffix {
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

/* ── Editor layout ────────────────────────────────── */
.editor-view {
    display: none; flex-direction: column;
    height: 100dvh; padding-top: 48px;
    overflow: hidden; position: relative;
}
.editor-view.active-view { display: flex; }

/* ── Header ───────────────────────────────────────── */
.neu-header {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.neu-icon-logo {
    width: 32px; height: 32px; border-radius: 10px;
    background: var(--accent); display: flex;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow-accent);
}
.neu-logo-big {
    width: 64px; height: 64px; border-radius: 18px;
    background: var(--accent-light); border: 1px solid var(--border-accent);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
}

/* ── Tab group ────────────────────────────────────── */
.neu-tab-group {
    display: flex; position: relative;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 3px;
}
.tab-slider {
    position: absolute; top: 3px; height: calc(100% - 6px);
    border-radius: 9px; background: var(--accent);
    box-shadow: var(--shadow-accent);
    transition: left .35s cubic-bezier(.4,0,.2,1), width .3s cubic-bezier(.4,0,.2,1);
    z-index: 0;
}
.tool-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 16px; font-size: 14px; font-weight: 700;
    color: var(--text-secondary); background: transparent; border: none;
    border-radius: 9px; cursor: pointer;
    transition: color .2s; white-space: nowrap;
    position: relative; z-index: 1;
}
.tool-tab:hover { color: var(--text); }
.tool-tab.active { color: #fff; }

/* ── Toolbar ──────────────────────────────────────── */
.neu-toolbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.tool-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; color: var(--text-secondary);
    background: transparent; border: 1px solid transparent;
    border-radius: 8px; cursor: pointer; transition: all .15s;
}
.tool-icon-btn:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.tool-icon-btn:active { background: var(--bg-surface); }
.tool-icon-btn.active { color: var(--accent); background: var(--accent-light); border-color: var(--border-accent); }

.ratio-btn {
    display: inline-flex; align-items: center;
    padding: 7px 12px; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); background: transparent;
    border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer; transition: all .15s; white-space: nowrap;
}
.ratio-btn:hover { color: var(--text); background: var(--bg-hover); }
.ratio-btn.active {
    color: #fff; background: var(--accent); border-color: var(--accent);
    box-shadow: var(--shadow-accent);
}
.sep { width: 1px; height: 20px; background: var(--border-light); flex-shrink: 0; margin: 0 3px; }

.add-layer-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 16px; font-size: 14px; font-weight: 700;
    color: #fff; background: var(--accent); border: none;
    border-radius: 8px; cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: all .15s;
}
.add-layer-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.add-layer-btn:active { transform: translateY(0); }

.auto-detect-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 16px; font-size: 14px; font-weight: 600;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer; transition: all .15s;
}
.auto-detect-btn:hover { background: var(--bg-hover); }
.auto-detect-btn:active { background: var(--bg-surface); }
.auto-detect-btn:disabled { opacity: .4; cursor: wait; }

/* ── Sidebar ──────────────────────────────────────── */
.neu-sidebar {
    background: var(--bg);
    border-left: 1px solid var(--border);
}
@media (max-width: 1023px) {
    .neu-sidebar { border-left: none; border-top: 1px solid var(--border); }
}
.neu-divider { height: 1px; background: var(--border-light); }

/* ── Panel elements ───────────────────────────────── */
.panel-label {
    display: block; font-size: 13px; font-weight: 700;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: .04em; margin-bottom: 8px;
}
.seg-btn {
    padding: 10px 8px; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer; transition: all .2s; text-align: center;
}
.seg-btn:hover { color: var(--text); background: var(--bg-hover); border-color: #d1d5db; }
.seg-btn:active { transform: scale(.97); }
.seg-btn.active {
    color: #fff; background: var(--accent); border-color: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}
.input-field {
    padding: 10px 12px; font-size: 15px; font-weight: 500;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    outline: none; transition: all .15s; font-family: inherit;
}
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-field::placeholder { color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 20px; font-size: 15px; font-weight: 700;
    color: #fff; background: var(--accent); border: none;
    border-radius: 10px; cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: all .2s;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow-strong); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-secondary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 20px; font-size: 15px; font-weight: 600;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 10px;
    cursor: pointer; transition: all .2s;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-secondary:active { transform: scale(.98); }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }

.neu-btn-accent {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 12px 28px; font-size: 14px; font-weight: 700;
    color: #fff; background: var(--accent); border: none; border-radius: 12px;
    box-shadow: var(--shadow-accent);
    transition: all .2s;
}
.neu-btn-accent:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 8px 25px var(--accent-glow-strong); }
.neu-btn-accent:active { transform: translateY(0); }

/* ── Toggle ───────────────────────────────────────── */
.toggle { position: relative; display: inline-flex; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    width: 44px; height: 24px; background: var(--border);
    border-radius: 999px; position: relative;
    transition: background .3s cubic-bezier(.4,0,.2,1);
}
.toggle-thumb {
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px; background: #fff;
    border-radius: 50%; box-shadow: var(--shadow-sm);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), width .15s;
}
.toggle input:active + .toggle-track .toggle-thumb { width: 24px; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(20px);
    box-shadow: 0 0 8px var(--accent-glow);
}
.toggle input:checked:active + .toggle-track .toggle-thumb { transform: translateX(16px); width: 24px; }

/* ── Slider ───────────────────────────────────────── */
.slider {
    -webkit-appearance: none; appearance: none;
    height: 6px; background: var(--border);
    border-radius: 999px; outline: none; cursor: pointer; display: block;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px; background: var(--accent);
    border: 3px solid #fff; border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px var(--accent-glow), var(--shadow-sm);
    transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
    width: 20px; height: 20px; background: var(--accent);
    border: 3px solid #fff; border-radius: 50%; cursor: pointer;
}

/* ── Kbd ──────────────────────────────────────────── */
.neu-kbd {
    display: inline-block; padding: 2px 6px;
    font-size: 9px; font-weight: 700; font-family: monospace;
    color: var(--text-secondary); background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: 4px;
}

/* ── Cards ────────────────────────────────────────── */
.neu-card-inset {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}
.neu-icon-circle {
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--bg-surface); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
}

/* ── Layer items ──────────────────────────────────── */
.layer-item {
    border-radius: 10px; background: var(--bg);
    border: 1px solid var(--border);
    transition: all .2s; overflow: hidden;
    border-left: 3px solid var(--lc, var(--border));
    margin-bottom: 6px;
}
.layer-item:hover { background: var(--bg-hover); }
.layer-item.active {
    background: var(--accent-light);
    border-color: var(--border-accent);
    border-left-color: var(--lc);
}
.layer-settings { animation: layerSlideIn .25s ease-out; }
@keyframes layerSlideIn { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 500px; } }

.layer-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; cursor: pointer;
}
.layer-thumb {
    width: 44px; height: 44px; border-radius: 8px;
    object-fit: cover; flex-shrink: 0;
    border: 1px solid var(--border); background: var(--bg-surface);
}
.layer-badge {
    display: inline-block; padding: 2px 6px; margin-left: 4px;
    font-size: 10px; font-weight: 700;
    background: var(--accent); color: #fff;
    border-radius: 4px; vertical-align: middle;
}
.layer-del {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
    color: var(--text-muted); background: transparent; border: none;
    border-radius: 6px; cursor: pointer;
    opacity: 0; transition: all .15s; flex-shrink: 0;
}
.layer-item:hover .layer-del { opacity: 1; }
.layer-del:hover { color: #ef4444; background: #fef2f2; }

.layer-settings {
    padding: 12px 14px 14px;
    border-top: 1px solid var(--border-light);
    overflow: hidden;
}

/* Layer settings layout */
.ls-row { margin-bottom: 10px; }
.ls-row:last-child { margin-bottom: 0; }
.ls-label {
    display: block; font-size: 12px; font-weight: 700;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: .04em; margin-bottom: 6px;
}
.ls-flex { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ls-flex .input-field { flex: 1 1 0; min-width: 0; width: 0; }
.ls-x { color: var(--text-muted); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.ls-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 15px; font-weight: 600; color: var(--text);
}
.ls-hint { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-top: 3px; }

/* ── Canvas overlays ──────────────────────────────── */
.crop-overlay {
    position: absolute; border-radius: 2px;
    pointer-events: none; transition: opacity .2s, border-width .15s;
}
.crop-overlay[style*="pointer-events:auto"]:hover {
    opacity: 1 !important; border-width: 2.5px !important;
    box-shadow: 0 0 12px rgba(124,58,237,0.2);
}
.crop-overlay-label {
    position: absolute; top: -1px; left: -1px;
    padding: 2px 8px; font-size: 9px; font-weight: 800;
    font-family: 'Nunito', sans-serif; color: #fff;
    border-radius: 0 0 6px 0; white-space: nowrap;
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
}

/* ── Checkerboard ─────────────────────────────────── */
.checkerboard {
    background-image:
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
        linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    opacity: .5;
}

/* ── Cropper.js theme ─────────────────────────────── */
.cropper-modal { background: rgba(0,0,0,0.4); }
.cropper-view-box { outline: 2px solid rgba(255,255,255,0.8); border-radius: 1px; }
.cropper-dashed { border-color: rgba(255,255,255,0.5) !important; border-width: 1px !important; }
.cropper-line { background-color: rgba(255,255,255,0.4) !important; }
.cropper-point {
    width: 12px !important; height: 12px !important;
    background: #fff; border: 2px solid var(--accent);
    border-radius: 50%; opacity: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2), 0 0 6px var(--accent-glow);
}
.cropper-point.point-n, .cropper-point.point-s { width: 22px !important; height: 5px !important; border-radius: 3px; margin-left: -11px; }
.cropper-point.point-e, .cropper-point.point-w { width: 5px !important; height: 22px !important; border-radius: 3px; margin-top: -11px; }
.cropper-point.point-ne, .cropper-point.point-nw, .cropper-point.point-se, .cropper-point.point-sw { width: 12px !important; height: 12px !important; }
.cropper-center::before, .cropper-center::after { background-color: rgba(255,255,255,0.5); }
.cropper-face { background: transparent; }

/* ── Toast ────────────────────────────────────────── */
.neu-toast {
    background: var(--text); color: #fff;
    box-shadow: var(--shadow-lg);
}
#toast { font-family: inherit; max-width: 90vw; }

/* ── Drop zone ────────────────────────────────────── */
.drop-zone-inner {
    transition: all .2s;
    border: 1px dashed var(--border) !important;
    background: var(--bg-surface);
}
.drop-zone-inner:hover {
    background: var(--accent-light);
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── Custom ratio inputs ──────────────────────────── */
.custom-ratio-wrap { display: inline-flex; align-items: center; gap: 5px; animation: customIn .2s ease-out; }
.custom-ratio-wrap.hidden { display: none; }
@keyframes customIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.custom-ratio-input {
    width: 56px; padding: 6px; font-size: 13px; font-weight: 700; text-align: center;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    outline: none; font-family: inherit; -moz-appearance: textfield;
}
.custom-ratio-input::-webkit-inner-spin-button, .custom-ratio-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.custom-ratio-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.custom-ratio-x { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.custom-ratio-apply {
    padding: 6px 14px; font-size: 12px; font-weight: 700;
    color: #fff; background: var(--accent); border: none; border-radius: 8px;
    cursor: pointer; transition: all .15s;
}
.custom-ratio-apply:hover { background: var(--accent-hover); }

/* ── Ad slots ─────────────────────────────────────── */
.ad-slot { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-slot-sticky { position: sticky; top: 60px; width: 300px; min-height: 600px; }
.ad-slot-mobile { width: 320px; height: 100px; margin: 0 auto; }
.ad-placeholder {
    width: 100%; height: 100%; min-height: inherit;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    background: var(--bg-surface); border: 1px dashed var(--border);
    border-radius: 8px;
}

/* ── Batch optimizer ──────────────────────────────── */
.batch-progress-bar {
    width: 100%; height: 8px;
    background: var(--border); border-radius: 999px;
    overflow: hidden;
}
.batch-progress-fill {
    height: 100%; background: var(--accent);
    border-radius: 999px;
    transition: width .3s ease;
    background-image: linear-gradient(
        -45deg,
        rgba(255,255,255,0.15) 25%, transparent 25%,
        transparent 50%, rgba(255,255,255,0.15) 50%,
        rgba(255,255,255,0.15) 75%, transparent 75%
    );
    background-size: 20px 20px;
}
.batch-progress-fill.active {
    animation: batchStripes .8s linear infinite;
}
@keyframes batchStripes {
    from { background-position: 0 0; }
    to { background-position: 20px 0; }
}

.batch-thumb-card {
    position: relative; border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    overflow: hidden; aspect-ratio: 1;
    transition: all .15s;
}
.batch-thumb-card:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.batch-thumb-card img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.batch-thumb-card .batch-thumb-name {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 2px 4px; font-size: 8px; font-weight: 700;
    color: #fff; background: rgba(0,0,0,0.6);
    text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    line-height: 1.4;
}
.batch-thumb-card .batch-thumb-size {
    position: absolute; top: 3px; right: 3px;
    padding: 1px 4px; font-size: 7px; font-weight: 800;
    color: #fff; background: rgba(0,0,0,0.5);
    border-radius: 3px;
}
.batch-thumb-card .batch-thumb-status {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; pointer-events: none;
}
.batch-thumb-card .batch-thumb-remove {
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; color: #fff;
    background: rgba(0,0,0,0.5); border: none;
    border-radius: 4px; cursor: pointer;
    opacity: 0; transition: opacity .15s;
}
.batch-thumb-card:hover .batch-thumb-remove { opacity: 1; }
.batch-thumb-card.processing {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.batch-thumb-card.done { opacity: .7; }
.batch-thumb-card.error { border-color: #ef4444; }

/* ── Scrollbar ────────────────────────────────────── */
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ────────────────────────────────────────────────────
   FAB BAR + BOTTOM SHEET (mobile only)
   Sidebar lateral em desktop vira bottom sheet em mobile,
   controlado pelos botões flutuantes "Ajustes" e "Baixar".
   ──────────────────────────────────────────────────── */

#fabBar { display: none; } /* default escondido em desktop */

@media (max-width: 1023px) {
    /* Sidebar vira bottom sheet escondido */
    .neu-sidebar {
        position: fixed !important;
        bottom: 0; left: 0; right: 0; top: auto !important;
        max-height: 80vh !important;
        z-index: 50;
        border-radius: 18px 18px 0 0;
        border-top: 1px solid var(--border);
        border-left: none !important;
        box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
        transform: translateY(100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        will-change: transform;
        padding-top: 18px; /* espaço pro grip */
    }
    .neu-sidebar.is-open { transform: translateY(0); }
    .neu-sidebar::before {
        content: '';
        position: absolute;
        top: 8px; left: 50%; transform: translateX(-50%);
        width: 40px; height: 4px;
        background: var(--border);
        border-radius: 999px;
        pointer-events: none;
    }

    /* Backdrop */
    #fabBackdrop {
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 49;
        opacity: 0; pointer-events: none;
        transition: opacity .2s;
    }
    #fabBackdrop.is-open { opacity: 1; pointer-events: auto; }

    /* FAB bar (botões flutuantes) */
    #fabBar {
        position: fixed;
        bottom: 16px; left: 16px; right: 16px;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        z-index: 40;
        pointer-events: none;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    #fabBar.is-hidden { display: none !important; }
    #fabBar > * { pointer-events: auto; }

    .fab-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 13px 22px;
        border-radius: 999px;
        font-weight: 700;
        font-size: 14px;
        border: none;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0,0,0,0.18);
        transition: transform .1s, opacity .15s;
        font-family: inherit;
    }
    .fab-btn:active { transform: scale(.96); }
    .fab-btn:disabled { opacity: .4; cursor: not-allowed; }

    .fab-tools {
        background: white;
        color: var(--text);
        border: 1px solid var(--border);
    }
    .fab-download {
        background: var(--accent);
        color: white;
    }
}

/* ── Focus ────────────────────────────────────────── */
button:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ══════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE
   Pattern: Bottom drawer + maximized canvas
   ══════════════════════════════════════════════════ */

/* Mobile < 1024px: sidebar becomes bottom drawer */
@media (max-width: 1023px) {
    /* Toolbar: compact, scrollable */
    .neu-toolbar .px-3 {
        padding: 6px 8px;
        gap: 4px;
    }

    /* Canvas: maximize space */
    #cropCanvas, .editor-view .flex-1.relative {
        min-height: 45vh;
    }

    /* Sidebar → Bottom drawer */
    .neu-sidebar {
        max-height: 45vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
        border-top: 1px solid var(--border);
        border-left: none !important;
    }

    /* Drag handle visual hint */
    .neu-sidebar::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 8px auto 4px;
    }

    /* Download buttons at bottom of drawer — safe area for browser chrome */
    .neu-sidebar > div:last-child {
        position: sticky;
        bottom: 0;
        background: var(--bg);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
        z-index: 2;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* Sidebar needs extra scroll room so content isn't hidden behind bottom bar */
    .neu-sidebar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* Ad slot hide on editor mobile (too intrusive) */
    .editor-view .ad-slot-sticky { display: none; }
}

/* Tablets / large phones < 768px: compact header tabs */
@media (max-width: 768px) {
    .tool-tab { padding: 6px 10px; font-size: 12px; gap: 4px; }
    .tool-tab svg { width: 12px; height: 12px; }
    .neu-tab-group { border-radius: 10px; padding: 2px; }
    .tab-slider { top: 2px; height: calc(100% - 4px); border-radius: 8px; }
}

/* Small mobile < 640px */
@media (max-width: 640px) {
    /* Header tabs: ícone-only é configurado mais abaixo (não duplicar aqui) */

    /* Toolbar: even more compact */
    .ratio-btn { padding: 4px 7px; font-size: 10px; }
    .tool-icon-btn { width: 28px; height: 28px; }
    .tool-icon-btn svg { width: 14px; height: 14px; }
    .add-layer-btn, .auto-detect-btn { padding: 4px 8px; font-size: 10px; }
    .sep { height: 16px; margin: 0 1px; }

    /* Sidebar drawer: larger on small screens */
    .neu-sidebar { max-height: 50vh; }

    /* Layer items: more compact */
    .layer-header { padding: 8px 10px; gap: 8px; }
    .layer-thumb { width: 36px; height: 36px; border-radius: 6px; }
    .layer-settings { padding: 10px 12px 12px; }

    /* Inputs: ensure touch targets 44px min */
    .input-field { padding: 10px 12px; min-height: 44px; }
    .seg-btn { padding: 10px 6px; min-height: 44px; }
    .toggle-track { width: 48px; height: 28px; }
    .toggle-thumb { width: 22px; height: 22px; top: 3px; left: 3px; }
    .toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
    .toggle input:checked:active + .toggle-track .toggle-thumb { transform: translateX(16px); }

    /* Buttons: full touch-friendly */
    .btn-primary, .btn-secondary { min-height: 48px; font-size: 14px; border-radius: 12px; }

    /* Slider: bigger thumb for touch */
    .slider { height: 8px; }
    .slider::-webkit-slider-thumb { width: 24px; height: 24px; }
}

/* ════════════════════════════════════════════════════
   BG REMOVAL TOOL — UI components
   ════════════════════════════════════════════════════ */

/* Status dot (toolbar) */
.ai-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.ai-dot-idle    { background: #9ca3af; }
.ai-dot-loading { background: #f59e0b; animation: ai-pulse 1.4s ease-in-out infinite; }
.ai-dot-ready   { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.ai-dot-error   { background: #ef4444; }
@keyframes ai-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* Loader (overlay processing) */
.bgr-loader { display: flex; gap: 6px; align-items: center; justify-content: center; }
.bgr-loader span {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent-gradient);
    box-shadow: 0 4px 14px var(--accent-glow);
    animation: bgr-loader-bounce 1s infinite ease-in-out both;
}
.bgr-loader span:nth-child(1) { animation-delay: -.32s; }
.bgr-loader span:nth-child(2) { animation-delay: -.24s; }
.bgr-loader span:nth-child(3) { animation-delay: -.16s; }
.bgr-loader span:nth-child(4) { animation-delay: -.08s; }
@keyframes bgr-loader-bounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: .5; }
    40%           { transform: scale(1.1); opacity: 1; }
}

/* Color swatches */
.bgr-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bgr-swatches-4 { grid-template-columns: repeat(4, 1fr); }
.bgr-swatch {
    position: relative;
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    padding: 6px 4px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.bgr-swatch:hover { border-color: var(--text-secondary); transform: translateY(-1px); }
.bgr-swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.bgr-swatch-color {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--c, transparent);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.bgr-swatch-checker {
    width: 32px; height: 32px;
    border-radius: 50%;
    background-image:
        linear-gradient(45deg, #d1d5db 25%, transparent 25%),
        linear-gradient(-45deg, #d1d5db 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d1d5db 75%),
        linear-gradient(-45deg, transparent 75%, #d1d5db 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,0.1);
}
.bgr-swatch-label {
    font-size: 9px; font-weight: 700;
    color: var(--text-secondary); line-height: 1;
}
.bgr-swatch.active .bgr-swatch-label { color: var(--accent-hover); }
.bgr-swatch-custom { cursor: pointer; }
.bgr-swatch-custom input {
    position: absolute; width: 0; height: 0;
    opacity: 0; border: 0; padding: 0;
}

/* Brush cursor */
.bgr-canvas-host { position: relative; touch-action: none; }
.bgr-brush-cursor {
    position: absolute; pointer-events: none;
    border: 2px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.6);
    z-index: 30;
    transition: width .1s, height .1s;
}
.bgr-brush-cursor.add { border-color: #22c55e; }
.bgr-brush-cursor.erase { border-color: #ef4444; }

/* Mobile: tabs viram só ícones, botão download compacto */
@media (max-width: 640px) {
    .tool-tab .tab-label { display: none; }
    .tool-tab { padding: 8px 11px; gap: 0; min-width: 0; }
    .tool-tab svg { width: 16px; height: 16px; }
    .bgr-download-btn { padding: 10px 18px; font-size: 13px; width: auto; min-width: 120px; }
}
