/* --- DESIGN (Deep Blue Theme) --- */
:root {
    --bg-gradient-start: #0f172a; 
    --bg-gradient-end: #020617;
    --glass-bg: rgba(15, 23, 42, 0.85); 
    --glass-border: rgba(56, 189, 248, 0.25);
    --accent-color: #38bdf8; 
    --accent-glow: rgba(56, 189, 248, 0.5);
    --private-color: #f43f5e; 
    --private-glow: rgba(244, 63, 94, 0.5);
    --text-main: #f8fafc; 
    --text-muted: #94a3b8;
}

body { 
    margin: 0; padding: 0; height: 100vh; width: 100vw; overflow: hidden; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    background: radial-gradient(circle at top center, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%); 
    color: var(--text-main); 
    -webkit-user-select: none; user-select: none; 
    -webkit-tap-highlight-color: transparent; 
}

* { scrollbar-width: none; box-sizing: border-box; } 
*::-webkit-scrollbar { display: none; }

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 999999;
    display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-main); padding: 12px 20px; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(10px);
    display: flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 500;
    transform: translateX(120%); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid var(--private-color); }

/* --- DOCK (Desktop Standard) --- */
.dock-container {
    position: fixed; bottom: 20px; left: 50%; 
    transform: translateX(-50%) translateY(20px) scale(0.8);
    opacity: 0.5;
    display: flex; gap: 15px; padding: 12px 25px;
    background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 20px; border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6); z-index: 10000; align-items: center;
    transform-origin: bottom center;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (hover: hover) {
    .dock-container:hover {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
}

.dock-separator { width: 1px; height: 40px; background: rgba(255,255,255,0.1); margin: 0 5px; flex-shrink: 0; }

.dock-item {
    width: 60px; height: 60px; border-radius: 14px; background: rgba(255,255,255,0.05);
    display: flex; justify-content: center; align-items: center; cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; 
    position: relative; border: 1px solid transparent; flex-shrink: 0;
}

.dock-item.dragging { opacity: 0.4; border: 1px dashed var(--accent-color); }
.dock-item.drag-over { transform: scale(1.1); border-color: var(--accent-color); background: rgba(56, 189, 248, 0.2); }
.dock-item:hover:not(.dragging) { transform: translateY(-10px) scale(1.15); background: rgba(255,255,255,0.1); border-color: var(--accent-color); box-shadow: 0 0 20px var(--accent-glow); z-index: 10; }
.dock-item.private-app { border-color: rgba(244, 63, 94, 0.3); }
.dock-item.private-app:hover { border-color: var(--private-color); box-shadow: 0 0 20px var(--private-glow); }
.dock-item img { width: 70%; height: 70%; object-fit: cover; pointer-events: none; border-radius: 8px; }

@media (hover: hover) {
    .dock-item:hover::after { content: attr(data-title); position: absolute; top: -40px; left: 50%; transform: translateX(-50%); background: #0f172a; border: 1px solid var(--accent-color); color: var(--accent-color); padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; white-space: nowrap; opacity: 0; animation: fadeIn 0.2s forwards; pointer-events: none; }
}
@keyframes fadeIn { to { opacity: 1; } }

.dock-indicator { position: absolute; bottom: -6px; width: 5px; height: 5px; background-color: var(--accent-color); border-radius: 50%; box-shadow: 0 0 8px var(--accent-glow); opacity: 0; transition: opacity 0.3s; }
.dock-item.running .dock-indicator { opacity: 1; }
.lock-btn { font-size: 24px; background: rgba(0,0,0,0.2); }
.lock-btn.unlocked { color: var(--private-color); text-shadow: 0 0 10px var(--private-glow); }
.add-app-btn { font-size: 28px; color: var(--accent-color); background: rgba(56, 189, 248, 0.08); border: 1px dashed var(--glass-border); }
.note-btn { font-size: 24px; background: rgba(253, 224, 71, 0.1); }
.note-btn:hover { border-color: #fef08a !important; box-shadow: 0 0 20px rgba(253, 224, 71, 0.5) !important; }
.trash-btn { font-size: 24px; background: rgba(239, 68, 68, 0.1); }
.trash-btn:hover { border-color: #fca5a5 !important; box-shadow: 0 0 20px rgba(239, 68, 68, 0.5) !important; }

/* --- STICKY NOTES --- */
.sticky-note {
    position: absolute; width: 220px; min-height: 220px;
    background: #fef08a; border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; color: #333;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}
.note-header {
    height: 30px; background: #fde047; cursor: grab;
    display: flex; justify-content: flex-end; align-items: center; padding: 0 10px;
}
.note-header:active { cursor: grabbing; }
.note-close { cursor: pointer; font-size: 14px; color: #ca8a04; transition: color 0.2s; font-weight: bold; }
.note-close:hover { color: #dc2626; }
.note-content {
    flex-grow: 1; padding: 15px; outline: none;
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    font-size: 1rem; line-height: 1.4; word-wrap: break-word; overflow-y: auto;
}
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- TRASH & CRUMPLED NOTES --- */
.trash-search {
    width: 90%; max-width: 500px; margin: 20px auto; padding: 12px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
    color: white; border-radius: 8px; font-size: 1rem; outline: none;
    transition: border-color 0.3s;
}
.trash-search:focus { border-color: var(--accent-color); }

.trash-grid {
    display: flex; flex-wrap: wrap; gap: 15px; padding: 20px 40px;
    overflow-y: auto; align-items: flex-start; justify-content: center;
    flex-grow: 1;
}

.crumpled-note {
    position: relative; width: 140px; height: 140px;
    background: linear-gradient(135deg, rgba(255,255,255,0.6) 0%, transparent 40%, rgba(0,0,0,0.15) 100%), #fef08a;
    box-shadow: 2px 5px 10px rgba(0,0,0,0.4), inset 0 0 15px rgba(0,0,0,0.1);
    border-radius: 4px 12px 6px 15px; /* Chaos Borders */
    padding: 15px; color: #333; font-size: 0.85rem; overflow: hidden;
    cursor: pointer; margin: -5px; /* Unterstützt das Überlagern */
    transition: all 0.4s ease-in-out;
    transform-origin: center center;
}
.crumpled-note::after {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.03) 10px, rgba(0,0,0,0.03) 12px);
    pointer-events: none;
}
.crumpled-note:hover {
    transform: scale(1.1) rotate(0deg) !important;
    box-shadow: 5px 15px 25px rgba(0,0,0,0.6);
    z-index: 999 !important;
}
.crumpled-note.filtered-out {
    opacity: 0 !important;
    transform: scale(0) !important;
    margin: -70px !important; /* Lässt den freigewordenen Platz weich in sich zusammenfallen */
    pointer-events: none;
}

/* --- WINDOW (Desktop Standard) --- */
.window { position: absolute; width: 900px; height: 720px; background: rgba(15, 23, 42, 0.96); backdrop-filter: blur(30px); border-radius: 10px; border: 1px solid var(--glass-border); box-shadow: 0 30px 90px rgba(0,0,0,0.8); display: flex; flex-direction: column; overflow: hidden; animation: openWindow 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.window.active { border-color: var(--accent-color); box-shadow: 0 30px 90px rgba(0,0,0,0.9), 0 0 25px rgba(56, 189, 248, 0.1); z-index: 100; }
.window.private-window.active { border-color: var(--private-color); box-shadow: 0 30px 90px rgba(0,0,0,0.9), 0 0 25px rgba(244, 63, 94, 0.2); }
.window.attention { animation: shake 0.4s ease-in-out; }
.window.minimized { display: none !important; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes openWindow { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

.window-header { height: 44px; background: linear-gradient(to right, rgba(255,255,255,0.02), transparent); border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; justify-content: space-between; padding: 0 15px; cursor: grab; }
.window-header:active { cursor: grabbing; }
.window-title { color: var(--text-muted); font-size: 14px; font-weight: 500; text-transform: uppercase; pointer-events: none; }
.window-controls { display: flex; gap: 10px; }
.control-dot { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; transition: transform 0.1s; } 
.control-dot:hover { transform: scale(1.1); } 
.close-dot { background: #ef4444; } .min-dot { background: #f59e0b; } .max-dot { background: #10b981; }
.window-content { flex-grow: 1; position: relative; background: #000; overflow: hidden; }
.drag-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; display: none; }
.window.dragging .drag-overlay { display: block; } 
iframe { width: calc(100% + 18px); height: 100%; border: none; background: #fff; z-index: 20; position: relative; }

/* --- LOADER --- */
.loader {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.1); border-top: 3px solid var(--accent-color);
    border-radius: 50%; animation: spin 1s linear infinite; z-index: 5;
}
@keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* --- MODALS --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); z-index: 99999; justify-content: center; align-items: center; animation: fadeIn 0.2s; }
.modal-box { background: #0f172a; padding: 30px; border-radius: 16px; border: 1px solid var(--glass-border); text-align: center; width: 320px; box-shadow: 0 0 40px rgba(56, 189, 248, 0.1); position: relative; }
.modal-box h3 { color: var(--accent-color); margin-top: 0; font-weight: 400; letter-spacing: 1px; margin-bottom: 20px; }
input[type="text"], input[type="password"] { width: 100%; margin-bottom: 15px; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid #334155; color: white; border-radius: 8px; outline: none; font-size: 1rem; text-align: center; transition: border 0.3s; }
input:focus { border-color: var(--accent-color); }
.checkbox-wrapper { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; color: #94a3b8; }
.btn { padding: 12px 20px; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; margin: 5px; font-size: 1rem; transition: transform 0.1s; -webkit-appearance: none; }
.btn:active { transform: scale(0.95); }
.btn-primary { background: var(--accent-color); color: #020617; }
.btn-secondary { background: transparent; border: 1px solid #475569; color: #94a3b8; }
#pinInput { letter-spacing: 5px; font-weight: bold; font-size: 1.5rem; }

/* ========================================= */
/* === MOBILE OPTIMIZATION (iPhone 16 Pro Max) === */
/* ========================================= */
@media (max-width: 768px) {
    .dock-container {
        width: auto; max-width: 98%; 
        bottom: calc(10px + env(safe-area-inset-bottom));
        justify-content: flex-start; overflow-x: auto;
        padding: 8px 12px; gap: 8px; border-radius: 16px;
        -ms-overflow-style: none; scrollbar-width: none;
        transform: translateX(-50%) scale(1) translateY(0); opacity: 1;
    }
    .dock-container::-webkit-scrollbar { display: none; }
    
    .dock-item { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
    .dock-item img { width: 65%; height: 65%; }
    
    .dock-separator { height: 25px; margin: 0 2px; }
    .lock-btn { font-size: 18px; }
    .add-app-btn { font-size: 22px; }
    .note-btn, .trash-btn { font-size: 18px; }
    .dock-indicator { bottom: -4px; width: 4px; height: 4px; }

    .dock-item[draggable="true"] { touch-action: pan-x; }

    .window { width: 100% !important; height: 100% !important; top: 0 !important; left: 0 !important; border-radius: 0; border: none; }
    .window-header { padding-top: calc(10px + env(safe-area-inset-top)); height: calc(50px + env(safe-area-inset-top)); background: rgba(15, 23, 42, 0.95); }
    .min-dot, .max-dot { display: none; }
    .close-dot { width: 28px; height: 28px; background: #ef4444 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'%3E%3C/line%3E%3Cline x1='6' y1='6' x2='18' y2='18'%3E%3C/line%3E%3C/svg%3E") center/60% no-repeat; }
    .window { resize: none; }
    .modal-box { width: 90%; }
}