:root {
    --bg-body: #09090b;
    --bg-sidebar: #121212;
    --bg-panel: #18181b;
    --bg-input: #27272a;
    --border: #27272a;
    --primary: #fafafa;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --accent-bg: #ffffff;
    --accent-text: #000000;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar-width: 360px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    overflow: hidden;
    user-select: none;
}

a {color: inherit; text-decoration: none;}

/* --- LAYOUT SYSTEM --- */
.app-container { display: flex; width: 100%; height: 100%; position: relative; }

/* LEFT SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: margin-left 0.3s var(--ease-out), transform 0.3s var(--ease-out);
    flex-shrink: 0; z-index: 50;
    position: relative; 
}
.sidebar.collapsed { margin-left: calc(var(--sidebar-width) * -1); }

.sidebar-header {
    height: 60px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; border-bottom: 1px solid var(--border);
    flex-shrink: 0; background: var(--bg-sidebar);
}
.sidebar-close-mobile { display: none; background: none; border: none; color: white; cursor: pointer; }

/* SIDEBAR STICKY TOGGLE BUTTON */
.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    left: var(--sidebar-width);
    width: 48px; height: 48px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-left: 1px solid var(--bg-sidebar);
    border-radius: 0 12px 12px 0;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 70;
    transition: left 0.3s var(--ease-out), color 0.2s;
    box-shadow: 4px 0 12px rgba(0,0,0,0.2);
}
.sidebar-toggle-btn svg { pointer-events: none; }
.sidebar.collapsed + .sidebar-toggle-btn {
    left: 0;
    border-left: 1px solid var(--border);
    border-radius: 0 12px 12px 0;
    background: var(--bg-panel);
}
.sidebar-toggle-btn:hover { color: white; background: #27272a; }

/* SIDEBAR TOOLBAR */
.sidebar-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; gap: 8px;
    background: var(--bg-sidebar);
    flex-shrink: 0;
}

.search-container {
    flex: 1; position: relative;
    display: flex; align-items: center;
}
.search-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 30px 8px 32px; /* Changed padding-right to 30px */
    color: white; font-size: 13px;
    font-family: inherit;
    transition: 0.2s;
}
.search-input:focus { border-color: #52525b; }
.search-icon {
    position: absolute; left: 10px; pointer-events: none;
    color: var(--text-muted);
}
.search-clear {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px;
    background: transparent; border: none;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 10px; line-height: 1; padding: 0;
    transition: 0.2s;
}
.search-clear:hover { background: rgba(255,255,255,0.1); color: white; }

.sb-action-btn {
    width: 34px; height: 34px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s; flex-shrink: 0;
}
.sb-action-btn:hover { background: #3f3f46; color: white; }
.sb-action-btn.active { background: rgba(239, 68, 68, 0.2); color: #ef4444; border-color: #ef4444; }
.sb-action-btn.btn-clear:hover { background: rgba(239, 68, 68, 0.2); color: #ef4444; border-color: rgba(239, 68, 68, 0.5); }

/* --- HISTORY LIST --- */
.history-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto; 
    padding: 16px;
    display: flex; flex-direction: column; gap: 16px;
    scrollbar-color: var(--border) transparent;
    scroll-behavior: smooth;
}

@keyframes slideInItem { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.hist-item {
    background: var(--bg-input); border-radius: 12px;
    overflow: hidden; border: 1px solid var(--border); 
    display: flex; flex-direction: column;
    transition: 0.2s; position: relative;
    flex-shrink: 0; 
    animation: slideInItem 0.4s ease-out backwards;
}
.hist-item:hover { border-color: #52525b; }
.hist-item.active { border-color: white; }

.hist-main { display: flex; gap: 12px; padding: 10px; cursor: pointer; }

.hist-thumb {
    width: 80px; height: 80px; border-radius: 6px; 
    flex-shrink: 0; object-fit: cover; background: #000;
}

.hist-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }

.hist-prompt-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 6px;
    margin-bottom: 6px;
}

.hist-prompt { 
    font-size: 12px; line-height: 1.4; color: #e4e4e7; 
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.hist-meta { 
    font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-muted); 
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}

.copy-seed-btn, .copy-prompt-btn, .fav-toggle-btn {
    background: none; border: none; padding: 0; margin: 0;
    color: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0.6; transition: 0.2s; flex-shrink: 0;
}
.copy-seed-btn:hover, .copy-prompt-btn:hover { opacity: 1; color: white; }
.copy-seed-btn { padding: 0 4px 4px; }
.copy-prompt-btn { width: 16px; height: 16px; margin-top: 2px; }

.fav-toggle-btn { width: 16px; height: 16px; margin-top: 2px; margin-left: 2px; color: #71717a; }
.fav-toggle-btn:hover { color: #ef4444; opacity: 1; }
.fav-toggle-btn.is-fav { color: #ef4444; opacity: 1; fill: #ef4444; }
.fav-toggle-btn svg { transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.fav-toggle-btn:active svg { transform: scale(0.8); }

.hist-actions {
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
}
.hist-action-btn {
    flex: 1; background: transparent; border: none; 
    color: var(--text-muted); 
    display: flex; align-items: center; justify-content: center; /* Centering Icons */
    padding: 8px 4px; cursor: pointer; border-right: 1px solid rgba(255,255,255,0.05);
    transition: 0.2s; min-width: 0;
}
.hist-action-btn:last-child { border-right: none; }
.hist-action-btn:hover { background: rgba(255,255,255,0.05); color: white; }
.hist-action-btn.btn-delete:hover { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.load-more-container { padding: 10px 0; text-align: center; }
.btn-load-more {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px; padding: 8px 16px;
    border-radius: 20px; cursor: pointer; transition: 0.2s; width: 100%;
}
.btn-load-more:hover { background: #3f3f46; color: white; }

.back-to-top {
    position: absolute; bottom: 20px; right: 20px;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-bg); color: var(--accent-text);
    border: none; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease, transform 0.2s;
    z-index: 55;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { transform: translateY(-2px); }

/* MAIN CANVAS */
.main-stage {
    flex: 1; position: relative; display: flex; flex-direction: column;
}

.main-stage::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(#222 1px, transparent 1px);
    background-size: 40px 40px; 
    background-position: center center;
    z-index: 0;
    transition: all 0.5s ease;
}

.main-stage.waiting::before {
    background-image: radial-gradient(#666 1.5px, transparent 1.5px);
    animation: quantum-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.main-stage.waiting::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    z-index: 0;
    animation: shockwave 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.generating-msg {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.8); font-family: 'JetBrains Mono', monospace; font-size: 14px;
    letter-spacing: 2px; text-transform: uppercase; pointer-events: none;
    opacity: 0; transition: opacity 0.3s; z-index: 10;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}
.main-stage.waiting .generating-msg {
    opacity: 1;
    animation: breath 2s infinite ease-in-out;
}
@keyframes breath { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

@keyframes quantum-pulse {
    0%, 100% { background-size: 40px 40px; opacity: 0.3; }
    50% { background-size: 45px 45px; opacity: 1; }
}

@keyframes shockwave {
    0% { transform: scale(0.5); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
}

#layer-canvas {
    position: absolute; inset: 0; z-index: 1;
    display: flex; align-items: center; justify-content: center; cursor: grab;
    overflow: hidden; 
}
#layer-canvas:active { cursor: grabbing; }

.transform-container { display: flex; align-items: center; justify-content: center; will-change: transform; }
.transform-container.smooth { transition: transform 0.25s cubic-bezier(0.2, 0, 0.2, 1); }

.art-image { max-width: none; border-radius: 4px; display: none; box-shadow: 0 50px 100px -20px rgba(0,0,0,0.8); pointer-events: none; }
.art-image.visible { display: block; }

#layer-ui {
    position: absolute; inset: 0; z-index: 60; 
    pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between;
}
#layer-ui > * { pointer-events: auto; }

#layer-ui .top-bar { display: flex; justify-content: space-between; padding: 20px 20px 0; pointer-events: none; }
.top-bar > * { pointer-events: auto; }
.top-left-group { display: flex; gap: 12px; align-items: flex-start; }

/* CANVAS ACTIONS */
.canvas-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    flex-direction: column;
    gap: 12px;
    z-index: 20;
}
.canvas-actions.visible { display: flex; }

.action-btn-vertical {
    width: 32px; height: 32px;
    background: rgba(24,24,27,0.8);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.action-btn-vertical:hover { background: #3f3f46; color: white; transform: translateX(-2px); }
.action-btn-vertical.is-fav { color: #ef4444; border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.1); }
.action-btn-vertical.is-fav svg { fill: #ef4444; }

.dock-wrapper {
    width: 100%; display: flex; justify-content: center;
    padding-bottom: 30px; position: relative; z-index: 20;
}

.prompt-bar {
    width: 90%; max-width: 800px;
    background: rgba(20, 20, 23, 0.60); backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-radius: var(--radius-xl);
    display: flex; flex-direction: column;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.6);
    transition: all 0.3s ease;
    position: relative;
}

.prompt-area { width: 100%; padding: 16px 16px 4px 16px; }

textarea#prompt-input {
    width: 100%; background: transparent; border: none;
    color: white; font-family: inherit; font-size: 16px; line-height: 1.5;
    resize: none; min-height: 24px; max-height: 200px; padding: 0;
    scrollbar-color: var(--border) transparent;
}
textarea#prompt-input::placeholder { color: #52525b; }

.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 8px 8px 16px; border-top: 1px solid transparent;
}

.tools-left { display: flex; align-items: center; gap: 4px; }
.tool-wrapper { position: relative; display: inline-flex; align-items: center; }

.tool-btn {
    height: 36px; padding: 0 12px; border-radius: 8px;
    background: transparent; border: none; color: var(--text-muted);
    font-size: 13px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 6px; transition: 0.2s;
}
.tool-btn:hover, .tool-btn.active { background: rgba(255,255,255,0.08); color: white; }
.tool-btn svg { width: 18px; height: 18px; }

.gen-btn {
    height: 36px; padding: 0 20px; border-radius: 99px;
    background: var(--accent-bg); color: var(--accent-text);
    border: none; font-weight: 700; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; gap: 6px; transition: 0.2s;
}
.gen-btn:hover { opacity: 0.8; }
.gen-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.badge { width: 6px; height: 6px; background: #10b981; border-radius: 50%; display: none; }

.popover {
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    margin-bottom: 12px; width: 300px;
    background: #18181b; border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 12px;
    display: none; flex-direction: column; gap: 10px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    animation: fadeIn 0.15s ease; z-index: 100;
}
.popover.visible { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.popover-close-mobile {
    display: none; position: absolute; top: 12px; right: 12px;
    background: rgba(255,255,255,0.1); border: none; color: #a1a1aa;
    width: 24px; height: 24px; border-radius: 50%;
    align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; line-height: 1; padding: 0; z-index: 110;
}
.popover-close-mobile:hover { background: rgba(255,255,255,0.2); color: white; }

#menu-upload { width: 320px; }
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.upload-item { 
    position: relative; width: 100%; aspect-ratio: 1; 
    border-radius: 8px; overflow: hidden; background: #333; 
    border: 1px solid var(--border); 
}
.upload-img { width: 100%; height: 100%; object-fit: cover; }
.upload-remove { 
    position: absolute; top: 4px; right: 4px; 
    width: 20px; height: 20px; border-radius: 50%; 
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    color: white; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1; padding: 0;
    transition: 0.2s;
}
.upload-remove:hover { background: #ef4444; }
.upload-add { 
    width: 100%; aspect-ratio: 1; border-radius: 8px;
    border: 1px dashed #52525b; 
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #a1a1aa; transition: 0.2s;
}
.upload-add:hover { border-color: white; color: white; background: rgba(255,255,255,0.05); }

#menu-models { width: 240px; }
#menu-ratio { width: 280px; }
/* Replaced old menu-commerce width logic with wide-popover class */

.ratio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ratio-item {
    background: var(--bg-input); border-radius: 8px; height: 50px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    cursor: pointer; border: 1px solid transparent; color: var(--text-muted); font-size: 11px;
}
.ratio-item:hover { background: #3f3f46; color: white; }
.ratio-item.active { background: #3f3f46; border-color: white; color: white; }
.r-shape { border: 1.5px solid currentColor; border-radius: 2px; }

.model-opt { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: #a1a1aa; }
.model-opt:hover { background: var(--bg-input); color: white; }
.model-opt.active { background: var(--bg-input); color: white; font-weight: 600; }

.setting-row { display: flex; flex-direction: column; gap: 6px; }
.row-header { font-size: 11px; text-transform: uppercase; color: #71717a; font-weight: 700; }
select, input[type=number] { background: var(--bg-input); border: 1px solid var(--border); color: white; padding: 8px; border-radius: 6px; width: 100%; }

.seed-group { display: flex; gap: 8px; }
.seed-btn { width: 36px; background: #333; border: 1px solid var(--border); border-radius: 6px; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.switch-row { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-top: 4px; }
.switch-label { font-size: 13px; color: white; }

/* Advanced Settings Styling */
.adv-divider { height: 1px; background: var(--border); margin: 8px 0; }
.row-header-flex { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; color: #71717a; font-weight: 700; margin-bottom: 6px; }
.val-display { color: #4ade80; font-family: 'JetBrains Mono', monospace; }

input[type=range] {
    -webkit-appearance: none; width: 100%; background: transparent; padding: 0; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 4px; background: #3f3f46; border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 14px; width: 14px; border-radius: 50%;
    background: white; margin-top: -5px; cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.btn-reset {
    background: transparent; border: 1px dashed #52525b; color: #a1a1aa;
    font-size: 10px; padding: 6px; border-radius: 6px; cursor: pointer;
    width: 100%; margin-top: 8px; transition: 0.2s;
}
.btn-reset:hover { border-color: #ef4444; color: #ef4444; }
.switch-row { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-top: 4px; }
.switch-label { font-size: 13px; color: white; }

.spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-spin { animation: spin 0.6s linear infinite; }

.sidebar-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.6); z-index: 40;
    opacity: 0; pointer-events: none; transition: 0.3s;
}

/* --- CREATIVE STUDIO (STYLES & COMMERCE) --- */
.wide-popover {
    width: 600px;
    max-width: 90vw;
    padding: 0;
    overflow: hidden;
}

.creative-tabs {
    display: flex;
    background: #121212;
    border-bottom: 1px solid var(--border);
    padding: 4px 4px 0 4px;
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #a1a1aa;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 0;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}
.tab-btn:hover { color: white; }
.tab-btn.active { color: white; border-bottom-color: white; }

.creative-content {
    height: 400px;
    overflow-y: auto;
    padding: 16px;
    scrollbar-color: var(--border) transparent;
}
.creative-content::-webkit-scrollbar { width: 6px; }
.creative-content::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }

.visual-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.visual-card {
    position: relative;
    aspect-ratio: 1;
    background: #27272a;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
}
.visual-card:hover { transform: translateY(-2px); }
.visual-card.active { border-color: white; box-shadow: 0 0 0 2px rgba(255,255,255,0.2); }

.vc-thumb {
    width: 100%; height: 100%; object-fit: cover;
    transition: 0.3s;
}
.visual-card:hover .vc-thumb { transform: scale(1.05); }

/* Fallback gradient if no image */
.vc-fallback {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #3f3f46, #18181b);
    display: flex; align-items: center; justify-content: center;
    color: #52525b;
}
.vc-fallback svg { opacity: 0.2; width: 40px; height: 40px; }

.vc-label-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    padding: 20px 8px 8px;
    color: white; font-size: 11px; font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
}

/* Color Picker in Creative Menu */
.color-picker-row {
    margin-bottom: 16px;
    background: var(--bg-input);
    padding: 10px; border-radius: 8px;
    display: flex; justify-content: space-between; align-items: center;
}

/* Section Dividers */
.grid-section-title {
    grid-column: 1 / -1;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    color: #71717a; margin: 16px 0 8px 0;
}
.grid-section-title:first-child { margin-top: 0; }

/* --- TOAST NOTIFICATION --- */
.toast {
    position: absolute;
    bottom: 120px; /* Position above the prompt bar */
    left: 50%;
    transform: translateX(-50%) translateY(20px); /* Start off-screen */
    background: #10b981; /* A nice success green */
    color: white;
    padding: 10px 20px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    z-index: 101;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .sidebar { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); margin-left: 0; }
    .sidebar.open { transform: translateX(0); z-index: 71; }
    .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
    .sidebar-close-mobile { display: block; }
    
    .sidebar-toggle-btn {
        position: absolute;
        top: 20px; left: 0;
        background: rgba(24,24,27,0.8);
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .dock-wrapper { bottom: 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
    .prompt-bar { 
        width: calc(100% - 20px); max-width: 100%; 
        border-radius: 20px; border-bottom: none; border-left: none; border-right: none; margin-bottom: 0; 
    }
    .popover {
        position: fixed; bottom: 0; left: 0; right: 0; width: 100% !important;
        top: auto; transform: none !important; margin: 0;
        border-radius: 20px; 
        padding: 40px 20px 20px 20px;
        border-left: none; border-right: none; border-bottom: none;
        animation: slideUpMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 80vh; 
    }
    .wide-popover { max-width: 100%; border-radius: 20px; }
    .creative-content { max-height: 60vh; }
    
    @keyframes slideUpMobile { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .tool-btn span { display: none; }
    .tool-btn { padding: 0 10px; }
    .gen-btn { padding: 0 12px; }
    #layer-canvas { padding-bottom: 80px; }
    .popover-close-mobile { display: flex; }
    .gen-text { display: none; }
    .gen-btn { padding: 0; width: 36px; justify-content: center; }
    
    .visual-grid { grid-template-columns: repeat(2, 1fr); }

    .toast {
        bottom: 110px;
        width: calc(100% - 40px);
        text-align: center;
    }
}