*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;outline:none;margin:0;padding:0}
input,textarea{-webkit-user-select:text!important;user-select:text!important}
body{font-family:'IBM Plex Sans Arabic',sans-serif;background:#f0f2f7;color:#1a1a2e;min-height:100vh;padding-bottom:100px;-webkit-user-select:none;user-select:none;overflow-x:hidden}

/* ── HEADER ── */
.header{background:linear-gradient(160deg,#4f46e5,#7c3aed);padding:48px 20px 28px;text-align:center;position:relative;border-radius:0 0 32px 32px;box-shadow:0 8px 30px rgba(79,70,229,.35)}
.header h1{color:#fff;font-size:1.9rem;font-weight:700;margin-bottom:3px}
.header p{color:rgba(255,255,255,.7);font-size:.85rem;font-weight:400}
.header-badge{display:inline-block;background:rgba(255,255,255,.15);color:#fff;font-size:.7rem;font-weight:600;letter-spacing:.1em;padding:4px 12px;border-radius:100px;margin-bottom:10px;border:1px solid rgba(255,255,255,.2)}

/* Cloud Status */
.cloud-status {position:absolute; top:20px; left:60px; font-size:0.75rem; color:rgba(255,255,255,0.9); display:flex; align-items:center; gap:6px; font-weight:600;}
.sync-loader {display:none; width:14px; height:14px; border:2px solid rgba(255,255,255,0.3); border-top:2px solid #fff; border-radius:50%; animation:spin 0.8s linear infinite;}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Header icon buttons */
.hdr-btn{position:absolute;top:48px;width:40px;height:40px;background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.2);border-radius:12px;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:background .2s}
.hdr-btn:active{background:rgba(255,255,255,.3)}
.hdr-btn svg{width:20px;height:20px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.hdr-btn-left{left:16px}
#mainSelectBtn{position:absolute;top:48px;right:16px;background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.25);border-radius:12px;color:#fff;font-family:'IBM Plex Sans Arabic';font-weight:600;font-size:.82rem;padding:8px 14px;cursor:pointer}

/* ── NAV BAR ── */
#navBar{display:none;align-items:center;gap:10px;background:#fff;padding:10px 16px;margin:14px 16px 0;border-radius:16px;box-shadow:0 2px 12px rgba(0,0,0,.08)}
.back-btn{display:flex;align-items:center;gap:6px;background:#f0f2f7;border:none;padding:8px 14px;border-radius:10px;cursor:pointer;font-family:'IBM Plex Sans Arabic';font-weight:600;font-size:.85rem;color:#4f46e5;transition:background .15s}
.back-btn:active{background:#e0e2f0}
.back-btn svg{width:16px;height:16px;stroke:#4f46e5;fill:none;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.current-path{color:#64748b;font-size:.85rem;font-weight:500;margin-right:auto}

/* ── SELECTION TOOLBAR ── */
.sel-toolbar{display:none;align-items:center;justify-content:center;gap:6px;padding:0 12px;margin-top:12px;flex-wrap:wrap}
.sel-toolbar.active{display:flex}
.toolbar-btn{display:flex;align-items:center;gap:4px;background:#fff;border:1.5px solid #e2e8f0;padding:8px 12px;border-radius:12px;cursor:pointer;font-family:'IBM Plex Sans Arabic';font-weight:600;font-size:.8rem;color:#374151;box-shadow:0 2px 6px rgba(0,0,0,.05);transition:all .15s;flex:1;justify-content:center;}
.toolbar-btn:active{transform:scale(.95)}
.toolbar-btn svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.toolbar-btn.danger{color:#ef4444;border-color:rgba(239,68,68,.25);background:rgba(239,68,68,.04)}
.toolbar-btn.primary{color:#4f46e5;border-color:rgba(79,70,229,.25);background:rgba(79,70,229,.04)}
.toolbar-btn.opt{color:#8b5cf6;border-color:rgba(139,92,246,.25);background:rgba(139,92,246,.04)}

/* ── SEARCH ── */
.search-wrap{position:relative;margin:16px 16px 0}
.search-wrap svg.si{position:absolute;right:14px;top:50%;transform:translateY(-50%);width:18px;height:18px;stroke:#94a3b8;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
#searchInput{width:100%;padding:13px 44px 13px 44px;background:#fff;border:2px solid transparent;border-radius:16px;font-family:'IBM Plex Sans Arabic';font-size:.95rem;color:#1a1a2e;text-align:right;box-shadow:0 2px 12px rgba(0,0,0,.07);transition:all .25s}
#searchInput::placeholder{color:#94a3b8}
#searchInput:focus{border-color:#4f46e5;box-shadow:0 0 0 4px rgba(79,70,229,.1)}
.clear-btn{position:absolute;left:12px;top:50%;transform:translateY(-50%);width:28px;height:28px;background:#e2e8f0;border-radius:50%;display:none;align-items:center;justify-content:center;cursor:pointer}
.clear-btn svg{width:14px;height:14px;stroke:#64748b;fill:none;stroke-width:2.5;stroke-linecap:round}

/* ── GRID ── */
.grid-container{display:grid;grid-template-columns:repeat(auto-fill,minmax(155px,1fr));gap:14px;padding:16px;align-items:start}
.note-card{background:#fff;border-radius:22px;padding:16px 12px 12px;height:165px;display:flex;flex-direction:column;align-items:center;cursor:pointer;position:relative;text-align:center;box-shadow:0 3px 14px rgba(0,0,0,.08);border:2px solid transparent;transition:transform .2s cubic-bezier(.34,1.56,.64,1),box-shadow .2s,border-color .2s;touch-action:pan-y;overflow:hidden}
.note-card:active{transform:scale(.96)}
.note-card.is-folder{background:linear-gradient(160deg,#fffbeb,#fff);border-color:rgba(245,158,11,.2)}
.note-card.is-note{background:linear-gradient(160deg,#f5f3ff,#fff);border-color:rgba(124,58,237,.15)}
.note-card.selected{border-color:#10b981;background:linear-gradient(160deg,#ecfdf5,#fff)}
.note-card.dragging{opacity:.4;transform:scale(.93)}
.note-card.drag-target,.note-card.drag-target-hover{border-color:#4f46e5;background:linear-gradient(160deg,#eef2ff,#fff);transform:scale(1.04)}
.note-card.dragging-mobile{position:fixed;z-index:9999;opacity:.92;box-shadow:0 20px 50px rgba(0,0,0,.25);pointer-events:none;width:155px;height:165px;border:2px solid #4f46e5}

.card-icon-wrap{width:52px;height:52px;border-radius:16px;display:flex;align-items:center;justify-content:center;margin-bottom:8px;margin-top:4px}
.card-icon-wrap.folder-ico{background:linear-gradient(135deg,#f59e0b,#d97706)}
.card-icon-wrap.note-ico{background:linear-gradient(135deg,#7c3aed,#6d28d9)}
.card-icon-wrap.locked-ico{background:linear-gradient(135deg,#64748b,#475569)}
.card-icon-wrap svg{width:26px;height:26px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

.card-title{font-size:.88rem;font-weight:600;color:#1e293b;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;width:100%;max-height:2.8em}
.card-count{margin-top:auto;margin-bottom:2px;background:#f1f5f9;padding:3px 10px;border-radius:100px;font-size:.7rem;color:#64748b;font-weight:600}
.card-sel-icon{position:absolute;top:8px;right:8px;width:22px;height:22px;border-radius:50%;border:2px solid #10b981;background:#fff;display:none;align-items:center;justify-content:center}
.card-sel-icon svg{width:12px;height:12px;stroke:#fff;fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.note-card.selected .card-sel-icon{background:#10b981;display:flex}
.sort-handle{position:absolute;bottom:7px;right:7px;padding:5px;cursor:grab;opacity:.3;transition:opacity .2s}
.sort-handle svg{width:16px;height:16px;stroke:#64748b;fill:none;stroke-width:2;stroke-linecap:round}

/* ── EMPTY ── */
.empty-state{grid-column:1/-1;text-align:center;padding:60px 20px;color:#94a3b8}
.empty-state svg{width:56px;height:56px;stroke:#cbd5e1;fill:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;margin-bottom:14px}
.empty-text{font-size:.95rem;font-weight:500}

/* ── FAB ── */
.fab{position:fixed;bottom:28px;left:24px;width:56px;height:56px;border-radius:18px;background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;border:none;box-shadow:0 8px 24px rgba(79,70,229,.45);cursor:pointer;z-index:1000;display:flex;align-items:center;justify-content:center;transition:transform .2s cubic-bezier(.34,1.56,.64,1)}
.fab:active{transform:scale(.9)}
.fab svg{width:26px;height:26px;stroke:#fff;fill:none;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.paste-fab{position:fixed;bottom:28px;left:50%;transform:translateX(-50%);background:linear-gradient(135deg,#059669,#047857);color:#fff;padding:14px 26px;border-radius:100px;border:none;font-family:'IBM Plex Sans Arabic';font-weight:700;font-size:.95rem;box-shadow:0 8px 24px rgba(5,150,105,.4);display:none;z-index:2000;align-items:center;gap:8px;cursor:pointer}
.paste-fab svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* ── CONTEXT MENU OVERLAY ── */
#ctxOverlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:4999;display:none;background:rgba(0,0,0,.35);backdrop-filter:blur(2px)}

/* ── MENUS ── */
.menu-sheet{position:fixed;bottom:0;left:0;right:0;background:#fff;border-radius:28px 28px 0 0;z-index:5000;display:flex;flex-direction:column;box-shadow:0 -10px 40px rgba(0,0,0,.18);padding:8px 0 24px;transform:translateY(110%);transition:transform .35s cubic-bezier(.32,0,.67,0);pointer-events:none}
.menu-sheet.open{transform:translateY(0);transition:transform .38s cubic-bezier(.34,1.15,.64,1);pointer-events:all}
.menu-handle{width:40px;height:4px;background:#e2e8f0;border-radius:100px;margin:10px auto 14px}
.menu-title{font-size:.8rem;font-weight:700;color:#94a3b8;letter-spacing:.08em;padding:0 20px 8px;text-transform:uppercase}

.menu-item{display:flex;align-items:center;gap:14px;padding:14px 20px;cursor:pointer;border:none;background:none;width:100%;font-family:'IBM Plex Sans Arabic';font-size:1rem;font-weight:500;color:#1e293b;text-align:right;transition:background .15s;position:relative}
.menu-item:active{background:#f8fafc}
.menu-item .m-icon{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.menu-item .m-icon svg{width:20px;height:20px;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.menu-item .m-label{flex:1;text-align:right}
.menu-item .m-arrow{color:#d1d5db}
.menu-item .m-arrow svg{width:16px;height:16px;stroke:#d1d5db;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.menu-sep{height:1px;background:#f1f5f9;margin:4px 20px}
.menu-item.red .m-label{color:#ef4444}
.menu-item.red .m-icon{background:rgba(239,68,68,.1)}
.menu-item.red .m-icon svg{stroke:#ef4444}
.menu-item.blue .m-icon{background:rgba(79,70,229,.1)}
.menu-item.blue .m-icon svg{stroke:#4f46e5}
.menu-item.green .m-icon{background:rgba(16,185,129,.1)}
.menu-item.green .m-icon svg{stroke:#10b981}
.menu-item.amber .m-icon{background:rgba(245,158,11,.1)}
.menu-item.amber .m-icon svg{stroke:#f59e0b}
.menu-item.violet .m-icon{background:rgba(139,92,246,.1)}
.menu-item.violet .m-icon svg{stroke:#8b5cf6}
.menu-item.slate .m-icon{background:rgba(100,116,139,.1)}
.menu-item.slate .m-icon svg{stroke:#64748b}

#createMenu{position:fixed;bottom:96px;left:16px;right:auto;width:200px;background:#fff;border-radius:20px;z-index:5000;display:none;flex-direction:column;box-shadow:0 8px 32px rgba(0,0,0,.18);padding:6px 0;transform-origin:bottom left}
#createMenu.open{display:flex;animation:popUp .2s cubic-bezier(.34,1.56,.64,1)}
@keyframes popUp{from{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}
.create-item{display:flex;align-items:center;gap:12px;padding:12px 16px;cursor:pointer;border:none;background:none;width:100%;font-family:'IBM Plex Sans Arabic';font-size:.9rem;font-weight:600;color:#1e293b;text-align:right;transition:background .15s}
.create-item:active{background:#f8fafc}
.create-item .ci-icon{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.create-item .ci-icon svg{width:18px;height:18px;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* ── MODALS ── */
.modal{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);z-index:6000;justify-content:center;align-items:center;backdrop-filter:blur(6px)}
.modal-full{position:fixed;top:0;left:0;width:100%;height:100%;z-index:6000;background:#f8fafc;flex-direction:column;display:none}
.modal-card{background:#fff;width:92%;max-width:340px;border-radius:28px;padding:28px 24px;box-shadow:0 20px 60px rgba(0,0,0,.2);animation:cardPop .25s cubic-bezier(.34,1.56,.64,1)}
@keyframes cardPop{from{opacity:0;transform:scale(.85) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}
.modal-msg{font-size:1.05rem;font-weight:600;margin-bottom:20px;line-height:1.6;color:#1e293b;text-align:center}
.modal-actions{display:flex;gap:10px;margin-top:10px}

/* ── BUTTON STYLES ── */
.btn{display:flex;align-items:center;justify-content:center;gap:7px;border:none;padding:13px 18px;border-radius:14px;cursor:pointer;font-family:'IBM Plex Sans Arabic';font-weight:700;font-size:.95rem;flex:1;transition:all .15s}
.btn:active{transform:scale(.96)}
.btn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.btn-primary{background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;box-shadow:0 4px 14px rgba(79,70,229,.35)}
.btn-danger{background:rgba(239,68,68,.1);color:#ef4444;border:1.5px solid rgba(239,68,68,.25)}
.btn-ghost{background:#f1f5f9;color:#64748b}
.btn-success{background:rgba(16,185,129,.1);color:#059669;border:1.5px solid rgba(16,185,129,.25)}
.btn-copy{background:rgba(139,92,246,.1);color:#7c3aed;border:1.5px solid rgba(139,92,246,.25)}

/* ── INPUT STYLES ── */
.inp{width:100%;padding:14px 16px;background:#f8fafc;border:2px solid #e2e8f0;border-radius:14px;font-family:'IBM Plex Sans Arabic';font-size:1rem;color:#1e293b;text-align:right;margin-bottom:18px;transition:border-color .2s}
.inp:focus{border-color:#4f46e5;background:#fff}
.inp::placeholder{color:#94a3b8}
.inp-area{width:100%;flex-grow:1;padding:16px;background:#f8fafc;border:2px solid #e2e8f0;border-radius:14px;font-family:'IBM Plex Sans Arabic';font-size:1rem;color:#1e293b;text-align:right;margin-bottom:14px;resize:none;overflow-y:auto;white-space:pre-wrap;line-height:1.7;transition:border-color .2s}
.inp-area:focus{border-color:#4f46e5;background:#fff}
.inp-pass{text-align:center;letter-spacing:.2em;font-size:1.1rem}

/* ── EDIT FULLSCREEN ── */
#editModal{background:#fff}
.edit-topbar{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1.5px solid #f1f5f9}
.edit-topbar .btn{flex:0;padding:10px 14px;font-size:.85rem}
.edit-search-bar{display:none;align-items:center;gap:8px;padding:10px 16px;background:#f8fafc;border-bottom:1.5px solid #e2e8f0}
.es-inp{flex:1;border:1.5px solid #e2e8f0;background:#fff;padding:8px 12px;border-radius:10px;font-family:'IBM Plex Sans Arabic';text-align:right;font-size:.9rem;color:#1e293b}
.es-btn{width:34px;height:34px;border:1.5px solid #e2e8f0;background:#fff;border-radius:10px;cursor:pointer;display:flex;align-items:center;justify-content:center}
.es-btn svg{width:16px;height:16px;stroke:#4f46e5;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* ── DETAILS MODAL ── */
#detailsModal{background:#f8fafc}
.details-topbar{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;background:#fff;border-bottom:1.5px solid #f1f5f9;gap:8px}
.note-title-label{font-size:1.25rem;font-weight:700;color:#4f46e5;padding:12px 16px 0}
.sub-notes-list{flex:1;overflow-y:auto;list-style:none;padding:10px 16px}
.sub-note-item{display:flex;align-items:flex-start;gap:12px;background:#fff;padding:13px 14px;margin-bottom:9px;border-radius:16px;box-shadow:0 2px 8px rgba(0,0,0,.05);border-right:3px solid #7c3aed;cursor:pointer;transition:all .2s}
.sub-note-item:active{background:#f5f3ff}
.sub-note-item.selected{border-right-color:#10b981;background:#f0fdf4}
.sub-note-content{flex:1;font-size:.95rem;line-height:1.55;color:#334155;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:pre-wrap}
.input-area{display:flex;gap:10px;padding:12px 16px;background:#fff;border-top:1.5px solid #f1f5f9}
#newSubNoteInput{flex:1;height:48px;padding:10px 14px;background:#f8fafc;border:2px solid #e2e8f0;border-radius:14px;font-family:'IBM Plex Sans Arabic';font-size:.95rem;color:#1e293b;text-align:right;transition:border-color .2s}
#newSubNoteInput:focus{border-color:#4f46e5;background:#fff}
.add-btn{width:48px;height:48px;background:linear-gradient(135deg,#4f46e5,#7c3aed);border:none;border-radius:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 12px rgba(79,70,229,.35);flex-shrink:0}
.add-btn:active{transform:scale(.93)}
.add-btn svg{width:22px;height:22px;stroke:#fff;fill:none;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.sub-search-wrap{padding:10px 16px;background:#fff;border-bottom:1px solid #f1f5f9}
#subSearchInput{width:100%;padding:10px 14px;background:#f8fafc;border:1.5px solid #e2e8f0;border-radius:12px;font-family:'IBM Plex Sans Arabic';font-size:.88rem;color:#1e293b;text-align:right;transition:border-color .2s}
#subSearchInput:focus{border-color:#4f46e5}

/* ── NOTIFICATION ── */
#notifToast{position:fixed;bottom:110px;left:50%;transform:translateX(-50%) translateY(20px);background:#1e293b;color:#fff;padding:12px 20px;border-radius:100px;font-size:.9rem;font-weight:600;z-index:9999;display:flex;align-items:center;gap:8px;box-shadow:0 8px 24px rgba(0,0,0,.25);opacity:0;transition:all .3s;pointer-events:none;white-space:nowrap}
#notifToast.show{opacity:1;transform:translateX(-50%) translateY(0)}
#notifToast svg{width:16px;height:16px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* ── DRAG ACTION SHEET ── */
.drag-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;padding:4px 20px 8px}
.drag-card{background:#f8fafc;border:2px solid #e2e8f0;border-radius:18px;padding:18px 10px;text-align:center;cursor:pointer;transition:all .2s}
.drag-card:active{transform:scale(.95)}
.drag-card.move-c{border-color:rgba(79,70,229,.3);background:#f0f0ff}
.drag-card.swap-c{border-color:rgba(245,158,11,.3);background:#fffbeb}
.drag-card .dc-icon{font-size:1.8rem;margin-bottom:6px}
.drag-card .dc-title{font-weight:700;font-size:.9rem;color:#1e293b;margin-bottom:2px}
.drag-card .dc-desc{font-size:.75rem;color:#64748b}

/* ── GOOGLE LOGIN OVERLAY ── */
#loginOverlay {position:fixed; top:0; left:0; right:0; bottom:0; background-color:#f0f2f5; z-index:7000; display:none; flex-direction:column; align-items:center; justify-content:center; padding:20px;}
.login-card {background:white; padding:40px; border-radius:16px; box-shadow:0 10px 30px rgba(0,0,0,0.1); text-align:center; width:100%; max-width:340px; font-family:'IBM Plex Sans Arabic', sans-serif;}
.google-btn {display:flex; align-items:center; justify-content:center; background-color:#1a73e8; color:white; border:none; padding:4px; border-radius:8px; font-size:1rem; font-weight:600; font-family:'IBM Plex Sans Arabic'; cursor:pointer; width:100%; transition:background-color 0.3s; text-decoration:none; margin-top:20px;}
.google-btn:hover {background-color:#1765cc;}
.google-icon-wrapper {background:white; padding:8px; border-radius:6px; display:flex; align-items:center; justify-content:center;}
.google-icon {width:20px; height:20px;}
.user-profile-img {width:24px; height:24px; border-radius:50%; object-fit:cover; border:1px solid #ddd;}

::-webkit-scrollbar{width:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:10px}