* { box-sizing: border-box; }
.code-scroll::-webkit-scrollbar { height: 8px; }
.code-scroll::-webkit-scrollbar-track { background: #1e1e1e; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.code-scroll::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
.code-scroll::-webkit-scrollbar-thumb:hover { background: #666; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.custom-scrollbar-code::-webkit-scrollbar { height: 6px; }
.custom-scrollbar-code::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.custom-scrollbar-code::-webkit-scrollbar-track { background: transparent; }
:root {
    --bg-main: #080808;
    --bg-island: rgba(20,20,20,0.8);
    --accent: #ffffff;
    --accent-text: #000000;
    --text-main: #e5e5e5;
    --text-dim: rgba(255,255,255,0.35);
    --border: rgba(255,255,255,0.08);
}
body {
    background-color: var(--bg-base, var(--bg-main)) !important;
    color: var(--text-main) !important;
    margin: 0;
    width: 100vw;
    max-width: 100%;
    height: calc(100dvh - 77px);
    display: flex;
    flex-direction: column;
    transition: background 1s ease, all 0.5s ease;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    overflow-x: hidden !important;
    background-image: radial-gradient(at 0% 0%, var(--bg-1) 0px, transparent 55%), radial-gradient(at 100% 0%, var(--bg-2) 0px, transparent 55%), radial-gradient(at 100% 100%, var(--bg-3) 0px, transparent 55%), radial-gradient(at 0% 100%, var(--bg-4) 0px, transparent 55%) !important;
    background-attachment: fixed !important;
    background-size: 100% 100% !important;
}
#bg-visual-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -2; transition: all 0.8s ease; display: none !important; }
#star-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
#main-layout { display: flex; width: 100%; height: 100% !important; position: relative; transition: all 0.5s ease; }
#left-panel { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; transition: all 0.5s ease; justify-content: center; }
#right-panel { flex: 0; width: 0; opacity: 0; overflow: hidden; border-left: 1px solid rgba(255,255,255,0.1); background: var(--bg-main) !important; color: var(--text-main) !important; transition: all 0.5s ease; display: flex; flex-direction: column; }
body.mode-code #left-panel { flex: 0 0 50%; }
body.mode-code #right-panel { flex: 1; opacity: 1; width: auto; padding: 20px; }
#top-zone { width: 100%; max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; position: relative; transition: all 0.6s cubic-bezier(0.16,1,0.3,1); }
#middle-zone { width: 90%; max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; z-index: 50; transition: all 0.6s cubic-bezier(0.16,1,0.3,1); padding:70px 0}
body:not(.started) #top-zone { flex: 0 0 0; opacity: 0; height: 0; padding: 0; overflow: hidden; }
body:not(.started) #middle-zone { flex: 1; justify-content: center}
body.started #top-zone { flex: 1; min-height: 0; opacity: 1; padding-bottom: 12px; }
body.started #middle-zone { flex: 0 0 auto; justify-content: flex-end}
.island-box { margin-bottom: 10px; width: 100%; background: var(--bg-island) !important; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 35px !important; position: relative; overflow: hidden; transition: transform 0.3s; border: none !important; outline: none !important; box-shadow: none !important; }
#prompt-input { color: var(--text-main) !important; caret-color: var(--accent) !important; border: none !important; outline: none !important; box-shadow: none !important; }
#prompt-input::placeholder { color: var(--text-dim) !important; }
.btn-icon { color: var(--text-dim) !important; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; }
.btn-icon.active, .btn-icon:hover { color: var(--accent) !important; transform: scale(1.1); text-shadow: 0 0 3px var(--accent); }
.btn-submit { background: var(--accent) !important; color: var(--accent-text) !important; border-radius: 50%; transition: all 0.2s; width: 40px !important; height: 40px !important; border: none !important; outline: none !important; box-shadow: none !important; }
.btn-submit i { color: var(--accent-text) !important; }
.btn-submit:hover { transform: scale(1.05); }
.btn-submit.stop-mode { background: #ff4444 !important; color: white !important; }

#welcome-msg { display: none !important; background: var(--border) !important; color: var(--text-main) !important; border: none !important; border-radius: 16px !important; padding: 10px 16px !important; }

.app-item, .store-item, .fixed-app-item { position: relative; display: flex; align-items: center; justify-content: center; background: var(--border) !important; border: 1.5px solid rgba(255,255,255,0.05) !important; border-radius: 18px !important; width: 48px !important; height: 48px !important; flex: 0 0 auto !important; cursor: pointer; transition: all 0.2s ease-out !important; box-shadow: none !important; }
.store-item:hover, .fixed-app-item:hover { background: rgba(255,255,255,0.15) !important; transform: scale(1.05); border-color: rgba(255,255,255,0.2) !important; }
.app-item img, .store-item img, .fixed-app-item img { padding:5px; width: 100%; height: 100%; object-fit: cover; border-radius: 16px; opacity: 0.85; transition: transform 0.2s; }
.store-item:hover img, .fixed-app-item:hover img { opacity: 1; }
.store-item span { display: none; }
.app-letter-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; color: white; border-radius: 12px; text-transform: uppercase; position: absolute; top: 0; left: 0; z-index: 0; }
.fixed-delete-btn { position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; background: #ef4444; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(0.8); transition: all 0.2s; z-index: 10; border: 1px solid rgba(255,255,255,0.2); }
.fixed-delete-btn i { font-size: 12px; filter: none !important; }
.fixed-app-item:hover .fixed-delete-btn { opacity: 1; transform: scale(1); }
#store-panel { max-height: 0; opacity: 0; overflow: hidden; transition: all 0.3s ease-in-out; margin: 0; padding: 0 16px; }
#store-panel.open { max-height: 800px; opacity: 1; margin-top: 8px; margin-bottom: 8px; padding-bottom: 8px; display: flex; flex-direction: column; }

#store-grid { display: grid !important; grid-template-columns: repeat(auto-fill, 50px) !important; justify-content: center !important; gap: 8px !important; padding: 4px !important; max-height: 120px !important; height: auto !important; overflow-y: auto !important; overflow-x: hidden !important; text-align: center; scrollbar-width: none; -ms-overflow-style: none; -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%); mask-image: linear-gradient(to bottom, black 80%, transparent 100%); }
#store-grid::-webkit-scrollbar { display: none; }

#app-container { width: 100% !important; max-width: 100% !important; padding: 0 4px !important; overflow: hidden !important; position: relative; box-sizing: border-box !important; }

#app-grid, #app-grid.search-scroll { display: flex !important; flex-wrap: wrap !important; justify-content: center !important; align-content: flex-start !important; align-items: flex-start !important; gap: 12px !important; width: 100% !important; max-height: 120px !important; height: auto !important; overflow-y: auto !important; overflow-x: hidden !important; padding: 4px 10px !important; animation: none !important; transform: none !important; cursor: default !important; box-sizing: border-box !important; -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%); mask-image: linear-gradient(to bottom, black 80%, transparent 100%); }

#app-grid::-webkit-scrollbar { width: 4px; }
#app-grid::-webkit-scrollbar-track { background: transparent; }
#app-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

#fixed-apps-list { display: flex !important; flex-wrap: wrap !important; justify-content: center !important; gap: 8px !important; width: 100% !important; padding: 0 10px !important; margin-bottom: 5px !important; }

.store-filter-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 10px; color: #888; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.05); transition: all 0.2s; flex-shrink: 0; }
.store-filter-btn:hover { background: rgba(255,255,255,0.15); color: white; transform: scale(1.05); }
.store-filter-btn.active { background: white; color: black; border-color: white; }
#loader-overlay { 
    position: absolute; 
    inset: 0; 
    border-radius: 28px; 
    background: rgba(20, 20, 20, 0.85);
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 100; 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.3s; 
    box-shadow: none;
}

#loader-overlay.active { 
    opacity: 1; 
    pointer-events: auto;
}
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-box { background: #151515; border: 1px solid rgba(255,255,255,0.15); border-radius: 24px; padding: 24px; width: 90%; max-width: 320px; text-align: center; transform: scale(0.95); transition: transform 0.3s; box-shadow: 0 20px 50px rgba(0,0,0,0.8); }
.modal-overlay.show .modal-box { transform: scale(1); }
.toast { position: fixed; top: 32px; left: 50%; transform: translateX(-50%) translateY(-20px); background: rgba(15,15,15,0.8); backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 12px 40px rgba(0,0,0,0.4); color: #efefef; padding: 12px 24px; border-radius: 16px; font-weight: 500; font-size: 0.85rem; opacity: 0; transition: all 0.5s ease; pointer-events: none; z-index: 1000; display: flex; align-items: center; gap: 10px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast::before { content: '✦'; color: #60a5fa; font-size: 1rem; }
#img-preview-container { display: none; transition: opacity 0.3s ease; }
#img-preview-container.active { display: block !important; opacity: 1 !important; visibility: visible !important; }
#preview-img { pointer-events: auto; max-height: 80vh; }
#chat-box { display: flex; flex-direction: column; height: 100%; overflow-y: auto; overflow-x: hidden; }
.mt-auto, #chat-box > div:first-child { margin-top: auto !important; }
#progress-bar { height: 100%; background: var(--accent) !important; width: 0; transition: all 0.3s; box-shadow: 0 0 10px var(--accent) !important; }
#code-tabs { background: var(--bg-island) !important; border-color: var(--border) !important; }

body.theme-light, body.theme-sky { background-color: #ffffff !important; background-image: radial-gradient(circle at 50% 40%, rgba(255,200,210,0.25) 0%, rgba(200,230,255,0.25) 30%, rgba(255,255,255,0) 70%) !important; color: #1a1a1a !important; }
body.theme-light .island-box, body.theme-sky .island-box { background: rgba(255,255,255,0.4) !important; }
body.theme-light .app-item, body.theme-light .store-item { background: #ffffff !important; }
body.theme-light .app-item img { filter: none !important; opacity: 0.8; }
body.theme-light #prompt-input { color: #000 !important; }
body.theme-light #prompt-input::placeholder { color: rgba(0,0,0,0.4) !important; }
body.theme-light .btn-submit { background: #000 !important; color: #fff !important; }
body.theme-light .btn-icon { color: #999 !important; }
body.theme-light .btn-icon:hover { color: #000 !important; background: transparent !important; }
body.theme-light #welcome-msg { display: none !important; }

body.theme-dark, body.theme-midnight { background-color: #0a0a0a !important; background-image: radial-gradient(circle at 50% 40%, rgba(50,60,100,0.4) 0%, rgba(30,30,40,0.4) 40%, rgba(10,10,10,0) 80%) !important; color: #e5e5e5 !important; }
body.theme-dark .island-box, body.theme-midnight .island-box { background: rgba(30,30,30,0.4) !important; }
body.theme-dark .app-item, body.theme-dark .store-item, body.theme-midnight .app-item, body.theme-midnight .store-item { background: #111111 !important; }
body.theme-dark .app-item img, body.theme-dark .store-item img { filter: brightness(0) invert(1) !important; opacity: 0.7 !important; }
body.theme-dark #prompt-input { color: #fff !important; }
body.theme-dark #prompt-input::placeholder { color: rgba(255,255,255,0.3) !important; }
body.theme-dark .btn-submit { background: #fff !important; color: #000 !important; }
body.theme-dark .btn-submit i { color: #000 !important; }
body.theme-dark .btn-icon { color: #666 !important; }
body.theme-dark .btn-icon:hover, body.theme-dark .btn-icon.active { color: #fff !important; background: transparent !important; }
body.theme-dark #welcome-msg { display: none !important; }

body.theme-midnight #bg-visual-layer { display: block !important; background: linear-gradient(180deg, #0f172a 0%, #020617 100%); }
body.theme-forest #bg-visual-layer { display: block !important; background: #0a0c0a; }

@media(max-width: 768px) {
    body.mode-code #left-panel { flex: 1 0 100% !important; width: 100% !important; max-width: 100% !important; }
    #right-panel { display: none !important; width: 0 !important; flex: 0 !important; }
    #right-panel.mobile-active { display: flex !important; position: fixed !important; top: 0; left: 0; right: 0; bottom: 0; width: 100% !important; height: 100% !important; z-index: 9999 !important; background: #151515; opacity: 1 !important; padding: 0 !important; margin: 0 !important; }
    #middle-zone { max-width: 100vw; margin: 0 auto}
    .island-box, textarea, #store-category-filters { max-width: 100%; }
}

#store-panel, #app-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, margin 0.3s ease;
    opacity: 0;
    padding: 0 12px;
}

#store-panel.open, #app-container.open {
    max-height: 150px;
    opacity: 1;
    margin-top: 10px;
    margin-bottom: 15px;
    overflow-y: auto !important;
}

#store-grid, #app-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    justify-content: start !important;
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

.store-item, .app-item, .fixed-app-item {
    width: 48px !important;
    height: 48px !important;
    flex-shrink: 0 !important;
    border-radius: 16px !important;
}

#store-category-filters {
    display: flex !important;
    padding: 0 4px 10px 0;
    gap: 8px;
}

#app-container {
    max-height: 0;
    overflow-y: auto;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    padding: 0 12px;
    scrollbar-width: none;
}

#app-container::-webkit-scrollbar {
    display: none;
}

#app-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    justify-content: center !important;
    padding: 4px 10px 40px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}
#chat-box::-webkit-scrollbar {
    width: 4px;
}

#chat-box::-webkit-scrollbar-track {
    background: transparent;
}

#chat-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

#chat-box {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.custom-scrollbar-code::-webkit-scrollbar {
    width: 4px;
}
.custom-scrollbar-code::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar-code::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.code-tab-btn {
    height: 28px;
    padding: 0 12px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.code-tab-btn.active {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}

.code-tab-btn:hover:not(.active) {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.02);
}