/* ── Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --brand: #7c3aed;
    --brand-l: #a855f7;
    --brand-d: #5b21b6;
    --accent: #06b6d4;
    --accent-l: #22d3ee;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-m: #475569;
    --text-s: #94a3b8;
    --radius: 16px;
}

.dark {
    --bg: #080c14;
    --surface: #111827;
    --border: #1e2d45;
    --text: #f0f6ff;
    --text-m: #94a3b8;
    --text-s: #475569;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background .3s, color .3s;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 99px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #1e3a5f;
}

.hide-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scroll::-webkit-scrollbar {
    display: none;
}

/* ── Glass ── */
.glass {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.glass-light {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

/* ── Glow ── */
.glow-brand {
    box-shadow: 0 0 24px rgba(124, 58, 237, .35);
}

.glow-accent {
    box-shadow: 0 0 24px rgba(6, 182, 212, .30);
}

/* ── Gradient text ── */
.grad-text {
    background: linear-gradient(135deg, var(--accent-l), var(--brand-l));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Header ── */
#app-header {
    background: linear-gradient(135deg, #0f172a 0%, #1a0533 50%, #072444 100%);
    border-bottom: 1px solid rgba(124, 58, 237, .25);
    box-shadow: 0 1px 0 rgba(124, 58, 237, .15), 0 4px 20px rgba(0, 0, 0, .4);
}

/* ── Sidebar ── */
#tool-sidebar {
    background: var(--surface);
    border-left: 1px solid var(--border);
    transition: background .3s, border-color .3s;
}

.tool-btn-side {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-s);
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
    position: relative;
    cursor: pointer;
}

.tool-btn-side:hover {
    background: rgba(124, 58, 237, .12);
    color: var(--brand-l);
    transform: scale(1.08);
}

.tool-btn-side.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, .25), rgba(6, 182, 212, .15));
    color: var(--brand-l);
    box-shadow: 0 0 0 1.5px rgba(124, 58, 237, .5), inset 0 1px 0 rgba(255, 255, 255, .1);
}

.tool-btn-side::after {
    content: attr(title);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    border: 1px solid rgba(255, 255, 255, .1);
}

.tool-btn-side:hover::after {
    opacity: 1;
}

/* ── Command Panel ── */
#cmd-panel {
    background: var(--surface);
    border-left: 1px solid var(--border);
    transition: background .3s, border-color .3s;
}

/* ── Generate Button ── */
#btn-generate,
#mobile-btn-generate {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    position: relative;
    overflow: hidden;
    transition: all .25s ease;
}

#btn-generate::before,
#mobile-btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, .15), transparent);
    opacity: 0;
    transition: opacity .2s;
}

#btn-generate:hover::before,
#mobile-btn-generate:hover::before {
    opacity: 1;
}

#btn-generate:hover,
#mobile-btn-generate:hover {
    box-shadow: 0 8px 32px rgba(124, 58, 237, .5), 0 0 0 1px rgba(255, 255, 255, .15);
    transform: translateY(-1px);
}

#btn-generate:active,
#mobile-btn-generate:active {
    transform: translateY(0);
}

#btn-generate:disabled,
#mobile-btn-generate:disabled {
    opacity: .55;
    transform: none;
    cursor: not-allowed;
}

/* ── Shortcut chips ── */
.chip {
    background: rgba(124, 58, 237, .08);
    border: 1px solid rgba(124, 58, 237, .2);
    color: var(--brand-l);
    border-radius: 99px;
    font-size: 11px;
    padding: 5px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chip:hover {
    background: rgba(124, 58, 237, .18);
    border-color: rgba(124, 58, 237, .4);
    transform: translateY(-1px);
}

.chip:active {
    transform: translateY(0);
}

/* ── Aspect cards ── */
.ratio-card input[type=radio] {
    display: none;
}

.ratio-card div {
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
    font-size: 11px;
    transition: all .2s;
    color: var(--text-m);
    background: rgba(255, 255, 255, .03);
}

.ratio-card input:checked+div {
    border-color: var(--brand);
    background: rgba(124, 58, 237, .12);
    color: var(--brand-l);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, .3);
}

.ratio-card div:hover {
    border-color: rgba(124, 58, 237, .4);
}

/* ── Aspect Ratio Chips (under Universal Prompt Bar & Home Prompt Box) ── */
.aspect-chip {
    display: inline-flex;
    align-items: center;
    position: relative;
    user-select: none;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.aspect-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.aspect-chip-inner {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3.5px 8.5px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.aspect-chip:hover .aspect-chip-inner {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(168, 85, 247, 0.4);
    color: #fff;
    transform: translateY(-1px);
}

.aspect-chip:active .aspect-chip-inner {
    transform: translateY(0);
}

.aspect-chip input[type="radio"]:checked+.aspect-chip-inner {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.45), rgba(6, 182, 212, 0.35));
    border-color: rgba(168, 85, 247, 0.9);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.aspect-chip input[type="radio"]:checked+.aspect-chip-inner i {
    color: #c084fc;
}

/* ── Home aspect ratio row ── */
.home-aspect-ratio-row {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.home-aspect-chips-list {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.home-aspect-chips-list::-webkit-scrollbar {
    display: none;
}

/* ── Workspace ── */
#workspace-container {
    touch-action: none;
    outline: none;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable both-edges;
    background:
        radial-gradient(ellipse 80% 60% at 60% 40%, rgba(124, 58, 237, .06) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 30% 70%, rgba(6, 182, 212, .04) 0%, transparent 70%),
        var(--bg);
}

#workspace-container.tool-brush {
    cursor: crosshair;
}

#workspace-container.tool-rect,
#workspace-container.tool-circle,
#workspace-container.tool-crop {
    cursor: crosshair;
}

#workspace-container.tool-pan {
    cursor: grab;
}

#workspace-container.tool-pan:active {
    cursor: grabbing;
}

#workspace-container.tool-text {
    cursor: text;
}

/* ── Canvas frame ── */
#image-display-wrapper {
    border-radius: 12px;
    box-shadow: 0 0 0 1.5px rgba(124, 58, 237, .5), 0 25px 80px rgba(0, 0, 0, .5);
    overflow: hidden;
}

#drawing-canvas {
    display: block;
    touch-action: none;
}

/* ── Empty state ── */
#empty-state {
    animation: fadeUp .5s ease;
}

.action-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 18px;
    padding: 18px 12px;
    cursor: pointer;
    transition: all .22s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 88px;
}

.action-card:hover {
    border-color: var(--brand);
    background: rgba(124, 58, 237, .06);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, .2);
}

.action-card:active {
    transform: translateY(-1px);
}

/* ── Upload area ── */
#upload-area {
    border: 2px dashed rgba(124, 58, 237, .3);
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    transition: all .2s;
    background: rgba(124, 58, 237, .04);
    text-align: center;
}

#upload-area:hover {
    border-color: var(--brand-l);
    background: rgba(124, 58, 237, .09);
}

/* ── Zoom controls & 4-Way Directional Controls ── */
#zoom-controls {
    bottom: 70px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 99px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    transition: all .15s;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

.zoom-btn:active {
    transform: scale(0.92);
    background: rgba(168, 85, 247, 0.3);
    color: #fff;
}

/* ── Workspace 4-Way Panning & Virtual Stage ── */
#workspace-container {
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-x pan-y;
    scroll-behavior: auto;
}

#workspace-container.space-panning {
    cursor: grab !important;
}

#workspace-container.space-panning:active {
    cursor: grabbing !important;
}

#workspace-container.tool-pan {
    cursor: grab;
}

#workspace-container.tool-pan:active {
    cursor: grabbing;
}

#workspace-container.has-image {
    display: block !important;
    padding: 0 !important;
    overflow: auto !important;
}

#workspace-container.has-image #workspace-inner {
    margin: 0 !important;
    min-width: 100% !important;
    min-height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 70vh 70vw !important;
    box-sizing: content-box !important;
}

#workspace-container.has-image #image-display-wrapper {
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

#workspace-container:not(.has-image) #workspace-inner {
    margin: auto !important;
    padding: 0 !important;
}

/* ── Universal Persistent Prompt Bar ── */
#universal-prompt-bar {
    display: flex !important;
    position: relative !important;
    z-index: 35 !important;
    width: 100% !important;
    background: rgba(15, 23, 42, 0.94) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4) !important;
}

#universal-prompt-input {
    background: rgba(0, 0, 0, 0.45) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    color: #fff !important;
    transition: all 0.2s ease !important;
}

#universal-prompt-input:focus {
    border-color: #a855f7 !important;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25) !important;
    background: rgba(0, 0, 0, 0.7) !important;
}

#btn-universal-generate {
    white-space: nowrap !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* ── Mobile Layer Quick Option Pill ── */
#mobile-layer-quick-bar {
    z-index: 55;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(168, 85, 247, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(168, 85, 247, 0.15);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

#mobile-layer-quick-bar:not(.hidden) {
    display: flex !important;
}

/* ── Smart popup ── */
#smart-popup {
    background: var(--surface);
    border: 1px solid rgba(124, 58, 237, .3);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(124, 58, 237, .15);
    pointer-events: auto;
}

#smart-popup-input {
    background: rgba(124, 58, 237, .06);
    border: 1.5px solid rgba(124, 58, 237, .25);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text);
    padding: 10px 12px;
    transition: border-color .2s;
}

#smart-popup-input:focus {
    outline: none;
    border-color: var(--brand-l);
}

/* ── Loading overlay ── */
#loading-overlay {
    background: rgba(8, 12, 20, .88);
    backdrop-filter: blur(12px);
}

/* ── Toast ── */
.toast {
    background: rgba(15, 23, 42, .92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
    color: #f1f5f9;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    animation: slideUp .3s cubic-bezier(.34, 1.56, .64, 1);
}

.toast.success {
    border-color: rgba(16, 185, 129, .4);
}

.toast.error {
    border-color: rgba(239, 68, 68, .4);
}

.toast.info {
    border-color: rgba(124, 58, 237, .4);
}

/* ── Modal overlay ── */
.modal-overlay {
    background: rgba(0, 0, 0, .75);
    backdrop-filter: blur(12px);
}

.modal-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 24px;
    box-shadow: 0 40px 120px rgba(0, 0, 0, .6);
}

/* ── Prompt textarea ── */
.prompt-area {
    background: rgba(124, 58, 237, .04);
    border: 1.5px solid rgba(124, 58, 237, .2);
    border-radius: 14px;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    line-height: 1.6;
    padding: 12px;
    resize: none;
    transition: border-color .2s;
}

.prompt-area:focus {
    outline: none;
    border-color: var(--brand-l);
}

.prompt-area::placeholder {
    color: var(--text-s);
}

/* ── Animations ── */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translate(-50%, 8px) scale(.94);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(124, 58, 237, .5);
    }

    70% {
        box-shadow: 0 0 0 14px rgba(124, 58, 237, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -12px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.anim-spin {
    animation: spin 1s linear infinite;
}

.anim-pulse-ring {
    animation: pulse-ring 2s infinite;
}

.anim-slide-down {
    animation: slideDown .25s cubic-bezier(.34, 1.56, .64, 1);
}

/* ── Toolbar ── */
#edit-toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: background .3s, border-color .3s;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 9px;
    font-size: 12px;
    color: var(--text-m);
    transition: all .15s;
    cursor: pointer;
}

.toolbar-btn:hover {
    background: rgba(124, 58, 237, .1);
    color: var(--brand-l);
}

.toolbar-btn.danger:hover {
    background: rgba(239, 68, 68, .1);
    color: #f87171;
}

/* ── Toolbar & Prompt Bar Visibility Rules ── */
#tool-sidebar.hidden,
#mobile-dock.hidden,
#universal-prompt-bar.hidden,
#crop-floating-bar.hidden {
    display: none !important;
}

#tool-sidebar:not(.hidden) {
    display: flex;
}

#universal-prompt-bar:not(.hidden) {
    display: flex;
}

#crop-floating-bar:not(.hidden) {
    display: flex;
}

/* ── Mobile editor dock ── */
#mobile-dock {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 5px 8px;
    height: 60px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.mob-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-m);
    cursor: pointer;
    transition: all .15s cubic-bezier(.4, 0, .2, 1);
    min-width: 52px;
    height: 50px;
    flex-shrink: 0;
    letter-spacing: .02em;
    user-select: none;
}

.mob-tool i {
    font-size: 20px;
}

.mob-tool:active {
    transform: scale(.92);
}

.mob-tool.active {
    background: rgba(124, 58, 237, .16);
    color: var(--brand-l);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, .35);
}

/* ── Pro badge ── */
.pro-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1c1007;
    font-weight: 900;
    letter-spacing: .05em;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    box-shadow: 0 0 14px rgba(251, 191, 36, .5);
}

/* ── Install button ── */
.install-btn {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #fff;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all .2s;
    animation: pulse-ring 2.5s infinite;
}

/* ── Selection status badge ── */
#selection-status {
    pointer-events: none;
    background: rgba(8, 12, 20, .85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(6, 182, 212, .4);
    border-radius: 99px;
    font-size: 11px;
}

/* ── Gallery card ── */
.gal-card {
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--border);
    cursor: pointer;
}

.gal-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
}

.gal-card:hover img {
    transform: scale(1.06);
}

.gal-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    transition: opacity .25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.gal-card:hover .gal-card-overlay {
    opacity: 1;
}

/* ─────────────────────────────────────────
   MOBILE OVERRIDES (≤ 640px)
───────────────────────────────────────── */
@media (max-width: 640px) {

    /* Hide desktop sidebar on mobile */
    #tool-sidebar {
        display: none !important;
    }

    /* App header: compact, clean spacing */
    #app-header {
        height: 52px !important;
        padding: 0 12px !important;
    }

    /* Workspace on mobile (when no image): clean block scrolling with top alignment */
    #workspace-container:not(.has-image) {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        padding: 0 !important;
    }

    #workspace-container:not(.has-image) #workspace-inner {
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 8px 10px 48px 10px !important;
        box-sizing: border-box !important;
    }

    #workspace-container.has-image {
        display: block !important;
        padding: 0 !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #workspace-container.has-image #workspace-inner {
        margin: 0 !important;
        padding: 60vh 60vw !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: content-box !important;
    }

    #workspace-container.has-image #image-display-wrapper {
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
    }

    /* Zoom control floating above prompt bar on mobile */
    #zoom-controls {
        bottom: 58px !important;
        padding: 4px 8px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    }

    /* Smart popup modal on mobile */
    #smart-popup {
        width: calc(100vw - 24px) !important;
        max-width: 380px !important;
        border-radius: 20px !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7) !important;
    }

    /* Empty state cards - modern compact list/grid */
    #empty-state {
        padding: 4px 4px 16px 4px !important;
        max-width: 100% !important;
        width: 100% !important;
        position: relative !important;
        z-index: 20 !important;
        pointer-events: auto !important;
        touch-action: pan-y !important;
    }

    #empty-state * {
        pointer-events: auto;
    }

    #empty-state .pointer-events-none {
        pointer-events: none !important;
    }

    #empty-state-icon {
        width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
        margin-bottom: 6px !important;
    }

    #empty-state-icon i {
        font-size: 20px !important;
    }

    #empty-state h2 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
        margin-bottom: 3px !important;
    }

    #empty-state p.empty-subtitle {
        font-size: 11px !important;
        margin-bottom: 10px !important;
        color: rgba(255, 255, 255, 0.6) !important;
    }

    #home-prompt-box {
        padding: 10px 10px 8px 10px !important;
        border-radius: 16px !important;
        margin-bottom: 8px !important;
    }

    #home-prompt-input {
        font-size: 12px !important;
        padding: 8px 10px !important;
        min-height: 44px !important;
        border-radius: 10px !important;
    }

    #btn-home-generate {
        padding: 7px 12px !important;
        font-size: 11.5px !important;
        border-radius: 10px !important;
    }

    .home-aspect-ratio-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        padding-top: 8px !important;
        margin-top: 8px !important;
    }

    .home-aspect-chips-list {
        width: 100% !important;
        overflow-x: auto !important;
        padding-bottom: 2px !important;
        gap: 5px !important;
    }

    #upload-area {
        padding: 10px 10px !important;
        border-radius: 14px !important;
    }

    #upload-area .w-9 {
        width: 32px !important;
        height: 32px !important;
        border-radius: 9px !important;
    }

    #btn-home-open-project {
        border-radius: 14px !important;
        padding: 8px 6px !important;
        width: 74px !important;
    }

    #empty-state .grid {
        gap: 6px !important;
    }

    .action-card {
        min-height: 72px !important;
        padding: 8px 4px !important;
        border-radius: 14px !important;
        background: rgba(255, 255, 255, 0.03) !important;
        border: 1px solid var(--border) !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
        text-align: center !important;
        transition: all 0.18s ease !important;
    }

    .action-card:active {
        transform: scale(0.96) !important;
        background: rgba(124, 58, 237, 0.12) !important;
        border-color: rgba(168, 85, 247, 0.5) !important;
    }

    .action-card .w-8 {
        width: 32px !important;
        height: 32px !important;
        border-radius: 9px !important;
        flex-shrink: 0 !important;
    }

    .action-card span {
        font-size: 10px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        text-align: center !important;
        color: rgba(255, 255, 255, 0.9) !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    /* Edit toolbar compact */
    #edit-toolbar {
        height: 42px !important;
        padding: 0 12px !important;
        background: rgba(15, 23, 42, 0.6) !important;
        backdrop-filter: blur(10px) !important;
    }

    /* Mobile Dock: streamlined touch toolbar */
    #mobile-dock {
        background: rgba(15, 23, 42, 0.96) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        height: 60px !important;
        padding: 5px 8px !important;
    }

    .mob-tool {
        min-width: 52px !important;
        height: 50px !important;
        padding: 5px 6px !important;
        border-radius: 12px !important;
        font-size: 10px !important;
        color: rgba(255, 255, 255, 0.75) !important;
    }

    .mob-tool i {
        font-size: 20px !important;
    }

    .mob-tool.active {
        background: rgba(124, 58, 237, 0.25) !important;
        color: #c084fc !important;
        box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.4) !important;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .mob-tool {
        min-width: 44px !important;
        padding: 5px 4px !important;
        font-size: 9px !important;
    }

    .mob-tool i {
        font-size: 18px !important;
    }

    .action-card span {
        font-size: 10px !important;
    }
}

/* ── Header buttons ── */
.hbtn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    transition: all .2s;
    cursor: pointer;
    white-space: nowrap;
}

.hbtn-ghost {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .15);
    color: #fff;
}

.hbtn-ghost:hover {
    background: rgba(255, 255, 255, .15);
    border-color: rgba(255, 255, 255, .25);
}

.hbtn-white {
    background: #fff;
    color: var(--brand-d);
}

.hbtn-white:hover {
    background: #ede9fe;
}

/* Preview checkerboard */
.checker-bg {
    background-image:
        linear-gradient(45deg, #1e2d45 25%, transparent 25%),
        linear-gradient(-45deg, #1e2d45 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1e2d45 75%),
        linear-gradient(-45deg, transparent 75%, #1e2d45 75%);
    background-size: 14px 14px;
    background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

/* Divider */
.v-div {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
}

/* section label */
.sec-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-s);
}

/* ═══════════════════════════════════════════════════════════
   STUDIO INSPECTOR & MOBILE BOTTOM SHEET
═══════════════════════════════════════════════════════════ */
.studio-panel,
#layers-panel {
    background: var(--surface);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s ease, opacity 0.2s ease;
}

/* ── Desktop Docked Inspector (≥ 641px) ── */
@media (min-width: 641px) {

    .studio-panel,
    #layers-panel {
        width: 340px !important;
        min-width: 340px !important;
        height: 100% !important;
        border-inline-start: 1px solid var(--border) !important;
        border-top: none !important;
        border-bottom: none !important;
        border-inline-end: none !important;
        border-radius: 0 !important;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25) !important;
        z-index: 25 !important;
        position: relative !important;
        display: flex !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .studio-panel.desktop-collapsed,
    #layers-panel.desktop-collapsed {
        width: 0 !important;
        min-width: 0 !important;
        border: none !important;
        opacity: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
    }
}

/* ── Mobile-First Bottom Sheet (< 641px) ── */
@media (max-width: 640px) {
    #mobile-prompt-bar {
        display: none !important;
    }

    #universal-prompt-bar.hidden {
        display: none !important;
    }

    #universal-prompt-bar:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        padding: 6px 8px 5px 8px !important;
        position: relative !important;
        z-index: 85 !important;
    }

    #universal-prompt-bar input {
        padding-top: 6px !important;
        padding-bottom: 6px !important;
        font-size: 12px !important;
    }

    #universal-prompt-bar button {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    #mobile-dock.hidden {
        display: none !important;
    }

    #mobile-dock:not(.hidden) {
        display: flex !important;
        position: relative !important;
        z-index: 85 !important;
    }

    /* Horizontal, compact tool size floating bars on mobile (Brush, Eraser & Crop) */
    #brush-floating-bar,
    #eraser-floating-bar,
    #crop-floating-bar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        white-space: nowrap !important;
        max-width: 96vw !important;
        width: max-content !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 4px 8px !important;
        gap: 5px !important;
        border-radius: 9999px !important;
        top: 54px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75) !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #brush-floating-bar.hidden,
    #eraser-floating-bar.hidden,
    #crop-floating-bar.hidden {
        display: none !important;
    }

    #brush-floating-bar::-webkit-scrollbar,
    #eraser-floating-bar::-webkit-scrollbar,
    #crop-floating-bar::-webkit-scrollbar {
        display: none !important;
    }

    #brush-floating-bar input[type="range"],
    #eraser-floating-bar input[type="range"] {
        width: 50px !important;
        min-width: 45px !important;
        height: 4px !important;
    }

    #brush-floating-bar button,
    #eraser-floating-bar button {
        padding: 4px 7px !important;
        font-size: 10px !important;
        gap: 3px !important;
        border-radius: 9999px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    #brush-floating-bar span,
    #eraser-floating-bar span {
        font-size: 10px !important;
        white-space: nowrap !important;
    }

    #brush-floating-bar i,
    #eraser-floating-bar i {
        font-size: 12px !important;
    }

    .studio-panel,
    #layers-panel {
        position: fixed !important;
        bottom: 104px !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 40vh !important;
        height: auto !important;
        border-radius: 20px 20px 0 0 !important;
        background: rgba(15, 23, 42, 0.96) !important;
        backdrop-filter: blur(28px) !important;
        -webkit-backdrop-filter: blur(28px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.16) !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.8) !important;
        z-index: 80 !important;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.24s ease, opacity 0.2s ease !important;
    }

    .studio-panel.sheet-closed,
    #layers-panel.sheet-closed {
        transform: translateY(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .studio-panel.sheet-open,
    #layers-panel.sheet-open {
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .studio-panel.sheet-peek,
    #layers-panel.sheet-peek {
        max-height: 44px !important;
        overflow: hidden !important;
    }

    #workspace-container.sheet-active-pad {
        padding-bottom: 42vh !important;
    }

    .sheet-drag-handle {
        width: 44px;
        height: 5px;
        background: rgba(255, 255, 255, 0.35);
        border-radius: 99px;
        margin: 0 auto;
        cursor: grab;
    }
}


.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    user-select: none;
    position: relative;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

.layer-item.active {
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.28), rgba(6, 182, 212, 0.15));
    border-color: rgba(168, 85, 247, 0.75);
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.3);
}

.layer-item.locked {
    background: rgba(15, 23, 42, 0.6);
}

.layer-item.hidden-layer {
    opacity: 0.45;
}

.layer-item.dragging {
    opacity: 0.35;
    border: 1px dashed #a855f7;
    background: rgba(124, 58, 237, 0.12);
}

.layer-item.drag-over-top {
    border-top: 2px solid #06b6d4 !important;
}

.layer-item.drag-over-bottom {
    border-bottom: 2px solid #06b6d4 !important;
}

.layer-drag-handle {
    cursor: grab;
    color: rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: 4px;
    transition: color 0.15s;
}

.layer-drag-handle:hover {
    color: rgba(255, 255, 255, 0.85);
}

.layer-drag-handle:active {
    cursor: grabbing;
}

.layer-action-btn {
    padding: 4px 6px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.45);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.layer-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.layer-action-btn.active {
    color: #a855f7;
}

.layer-action-btn.locked-active {
    color: #f59e0b;
}

.layer-title-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(168, 85, 247, 0.6);
    border-radius: 6px;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    outline: none;
    width: 100%;
}

/* Layer Properties Inspector Styling */
#layers-tab-content-props input[type="range"] {
    height: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    transition: background 0.2s;
}

#layers-tab-content-props input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #c084fc;
    box-shadow: 0 0 6px rgba(192, 132, 252, 0.6);
    cursor: pointer;
    transition: transform 0.1s;
}

#layers-tab-content-props input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#layers-tab-content-props input[type="color"] {
    -webkit-appearance: none;
    border: none;
    padding: 0;
}

#layers-tab-content-props input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

#layers-tab-content-props input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

/* ── Brush Floating Bar ── */
#brush-floating-bar {
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(168, 85, 247, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.75), 0 0 20px rgba(124, 58, 237, 0.25);
}

#smart-popup-drag-handle {
    cursor: grab;
}

#smart-popup-drag-handle:active {
    cursor: grabbing;
}

/* ── Eraser Floating Bar ── */
#eraser-floating-bar {
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(244, 63, 94, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.75), 0 0 20px rgba(244, 63, 94, 0.25);
}

#workspace-container.tool-eraser {
    cursor: crosshair;
}

/* ── Crop Floating Bar ── */
#crop-floating-bar {
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(6, 182, 212, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.75), 0 0 20px rgba(6, 182, 212, 0.25);
}

#crop-floating-bar.hidden {
    display: none !important;
}

#crop-floating-bar:not(.hidden) {
    display: flex !important;
}

#workspace-container.tool-crop {
    cursor: crosshair;
}

/* ─── Export Modal Styling ─── */
.export-format-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.15s ease;
}

.export-format-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(168, 85, 247, 0.4);
}

.export-format-btn.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(6, 182, 212, 0.2));
    border-color: #a855f7;
    color: #fff;
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

.export-scale-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-scale-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.export-scale-btn.active {
    background: rgba(168, 85, 247, 0.35);
    border-color: #a855f7;
    color: #fff;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

#export-modal input[type="range"] {
    height: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

#export-modal input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #c084fc;
    box-shadow: 0 0 6px rgba(192, 132, 252, 0.6);
    cursor: pointer;
}