:root {
    --ease: cubic-bezier(0.23, 1, 0.32, 1);
    
    /* Light Theme */
    --bg-main: #F2F2F7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --accent: #007AFF;
    --accent-glow: rgba(0, 122, 255, 0.3);
    --surface: #FFFFFF;
    --surface-hover: rgba(0, 0, 0, 0.05);
    --code-bg: #F5F5F7;
    --code-text: #1D1D1F;
    --danger: #FF3B30;
    --shadow: 0 8px 30px rgba(0,0,0,0.08);
    
    /* LOGO COLORS (LIGHT) */
    --logo: #2563EB;
    --logo-hover: #1D4ED8;
}

body.dark-mode {
    /* Dark Theme */
    --bg-main: #000000;
    --glass-bg: rgba(25, 25, 25, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-secondary: #98989F;
    --accent: #0A84FF;
    --accent-glow: rgba(10, 132, 255, 0.4);
    --surface: #1C1C1E;
    --surface-hover: #2C2C2E;
    --code-bg: #000000;
    --code-text: #EBEBF5;
    --shadow: 0 20px 50px rgba(0,0,0,0.5);

    /* LOGO COLORS (DARK) */
    --logo: #3B82F6;
    --logo-hover: #60A5FA;
}

* { box-sizing: border-box; outline: none; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    background: var(--bg-main); color: var(--text-primary);
    height: 100vh; overflow: hidden; transition: background 0.5s ease;
}

/* ФОН */
.ambient-bg { position: absolute; width: 100%; height: 100%; overflow: hidden; z-index: -1; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.4; transition: 1s ease; }
.orb-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: radial-gradient(circle, var(--accent) 0%, transparent 70%); animation: float 20s infinite alternate; }
.orb-2 { bottom: -10%; right: -10%; width: 40vw; height: 40vw; background: radial-gradient(circle, #BF5AF2 0%, transparent 70%); animation: float 25s infinite alternate-reverse; }
.orb-3 { top: 40%; left: 40%; width: 30vw; height: 30vw; background: radial-gradient(circle, #32D74B 0%, transparent 70%); animation: float 30s infinite alternate; opacity: 0.2; }
@keyframes float { 0% { transform: translate(0,0); } 100% { transform: translate(40px, 40px); } }

/* GLASS */
.glass {
    background: var(--glass-bg); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border); box-shadow: var(--shadow);
}

/* LOCK SCREEN */
.lock-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-main);
    z-index: 9999; display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: 0.5s var(--ease);
}
body.locked .lock-screen { opacity: 1; pointer-events: all; }
body.locked .app-layout { filter: blur(30px) scale(0.95); opacity: 0; }

.lock-card {
    width: 340px; padding: 40px; border-radius: 32px; text-align: center;
    display: flex; flex-direction: column; align-items: center;
}
.lock-icon-box {
    width: 70px; height: 70px; background: var(--surface); border-radius: 20px;
    display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--accent); margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.lock-card h2 { font-weight: 800; font-size: 24px; margin-bottom: 8px; }
.lock-card p { color: var(--text-secondary); margin-bottom: 30px; font-size: 14px; }
.lock-input-wrapper { position: relative; width: 100%; margin-bottom: 20px; }
.lock-input-wrapper input {
    width: 100%; background: var(--code-bg); border: 1px solid var(--glass-border); padding: 16px;
    border-radius: 16px; color: var(--text-primary); text-align: center; font-size: 18px; letter-spacing: 4px;
}
.lock-input-wrapper input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.btn-unlock {
    position: absolute; right: 6px; top: 6px; bottom: 6px; width: 44px; border: none; border-radius: 12px;
    background: var(--accent); color: white; cursor: pointer; transition: 0.2s;
}
.btn-unlock:hover { transform: scale(1.05); }
.btn-reset { background: none; border: none; color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.btn-reset:hover { color: var(--danger); }

/* LAYOUT */
.app-layout { display: flex; height: 100vh; padding: 16px; gap: 16px; transition: 0.5s var(--ease); }

/* SIDEBAR */
.sidebar { width: 280px; border-radius: 24px; display: flex; flex-direction: column; padding: 24px; z-index: 10; }

/* LOGO (Твой код) */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; padding: 0 8px; }
.logo-mark {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--logo), var(--logo-hover));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 20px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.logo-text span { color: var(--accent); }

.nav-wrapper { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.nav-header {
    display: flex; justify-content: space-between; align-items: center; font-size: 11px;
    font-weight: 700; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 12px; padding: 0 8px;
}
.icon-btn-mini { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; }
.icon-btn-mini:hover { color: var(--text-primary); }
.icon-btn-mini.active { color: var(--accent); }

/* CATEGORY TREE */
.category-tree { flex: 1; overflow-y: auto; }
ul { list-style: none; padding: 0; margin: 0; }
ul.nested-list { margin-left: 20px; border-left: 1px solid var(--glass-border); padding-left: 4px; display: none; }
ul.nested-list.open { display: block; }

.cat-item {
    display: flex; align-items: center; padding: 10px 12px; margin-bottom: 4px; border-radius: 12px;
    cursor: pointer; color: var(--text-secondary); font-weight: 500; font-size: 14px; transition: 0.2s; position: relative;
}
.cat-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.cat-item.active { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

/* Иконки в списке */
.cat-icon-box { width: 24px; text-align: center; margin-right: 8px; display: flex; align-items: center; justify-content: center; }
.cat-icon-box i { font-size: 16px; }

/* Кастомная SVG иконка (Маска) */
.custom-svg-icon {
    width: 18px; height: 18px;
    background-color: currentColor; /* Берет цвет текста */
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    opacity: 0.7;
}
.cat-item:hover .custom-svg-icon, .cat-item.active .custom-svg-icon { opacity: 1; }
.cat-item.active .custom-svg-icon { background-color: var(--accent); }
.cat-item.active i { color: var(--accent); }

/* Стрелочка папки */
.cat-arrow { font-size: 10px; margin-left: auto; transition: 0.2s; opacity: 0.5; margin-right: 20px; }
.cat-arrow.rotated { transform: rotate(90deg); }

/* Кнопка редактирования (Аккуратная) */
.btn-edit-cat {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; border: none; background: transparent; border-radius: 6px;
    color: var(--text-secondary); cursor: pointer; display: none; align-items: center; justify-content: center; font-size: 11px;
}
.cat-item:hover .btn-edit-cat { display: flex; }
.btn-edit-cat:hover { background: var(--bg-main); color: var(--text-primary); }

/* Drag & Drop */
.sortable-ghost { opacity: 0.4; background: var(--surface-hover); border: 1px dashed var(--accent); }

.sidebar-footer { display: flex; gap: 10px; margin-top: 16px; }
.btn-sidebar-main {
    flex: 1; background: var(--surface-hover); border: none; border-radius: 14px; height: 44px;
    color: var(--text-primary); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: 0.2s;
}
.btn-sidebar-main:hover { 
	background: rgba(255,255,255,0.1); 
	color: var(--accent); 
}

.btn-sidebar-icon {
    width: 44px; height: 44px; background: var(--surface-hover); border: none; border-radius: 14px;
    color: var(--text-secondary); cursor: pointer; transition: 0.2s;
}
.btn-sidebar-icon:hover { 
	background: rgba(255,255,255,0.1); 
	color: var(--danger); 
}

/* MAIN CONTENT */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header {
    height: 72px; margin-bottom: 16px; border-radius: 24px; padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between; z-index: 10;
}
.search-wrapper { position: relative; width: 380px; }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }
#searchInput {
    width: 100%; height: 44px; padding: 0 16px 0 46px; border-radius: 14px; border: none;
    background: var(--surface-hover); color: var(--text-primary); font-size: 14px; transition: 0.2s;
}
#searchInput:focus { background: var(--code-bg); box-shadow: 0 0 0 2px var(--accent); }

.header-actions { display: flex; gap: 10px; align-items: center; }
.action-btn {
    width: 40px; height: 40px; border-radius: 12px; border: none; background: transparent;
    color: var(--text-secondary); cursor: pointer; font-size: 18px; transition: 0.2s;
}
.action-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.divider { width: 1px; height: 24px; background: var(--glass-border); margin: 0 4px; }
.btn-primary {
    padding: 0 24px; height: 44px; background: var(--accent); color: white; border: none;
    border-radius: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 15px var(--accent-glow); transition: 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.1); }

/* GRID */
.scroll-container { flex: 1; overflow-y: auto; padding: 8px 8px 40px 8px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; }

.card {
    background: var(--surface); border: 1px solid var(--glass-border); border-radius: 20px;
    padding: 24px; display: flex; flex-direction: column; position: relative; transition: 0.3s var(--ease);
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: rgba(255,255,255,0.2); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.card-actions { display: flex; gap: 8px; opacity: 0; transition: 0.2s; }
.card:hover .card-actions { opacity: 1; }
.card-btn {
    width: 28px; height: 28px; border-radius: 8px; border: none; background: var(--bg-main);
    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.card-btn:hover { color: var(--text-primary); }
.card-btn.del:hover { color: var(--danger); background: rgba(255, 59, 48, 0.1); }

.code-wrapper {
    background: var(--code-bg); border-radius: 14px; padding: 16px;
    font-family: 'JetBrains Mono', 'Menlo', monospace; font-size: 13px; color: var(--code-text);
    line-height: 1.5; cursor: pointer; border: 1px solid transparent; transition: 0.2s;
    white-space: pre-wrap; word-break: break-all; position: relative;
}
.code-wrapper:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.copy-badge {
    position: absolute; top: 10px; right: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase;
    background: var(--accent); color: white; padding: 4px 8px; border-radius: 6px; opacity: 0; pointer-events: none;
    transition: 0.2s; transform: translateY(5px);
}
.code-wrapper:hover .copy-badge { opacity: 1; transform: translateY(0); }

/* MODALS */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px); z-index: 1000; display: none; justify-content: center; align-items: center;
}
.overlay.active { display: flex; animation: fadeIn 0.3s forwards; }
.modal {
    width: 420px; border-radius: 24px; padding: 30px; transform: scale(0.9); opacity: 0;
    transition: 0.3s var(--ease); background: var(--surface); border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}
.overlay.active .modal { transform: scale(1); opacity: 1; }
.modal.large { width: 600px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; font-weight: 700; margin: 0; }
.close-btn { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--glass-border);
    background: var(--bg-main); color: var(--text-primary); font-family: inherit; font-size: 15px;
    transition: 0.2s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.tab-switcher { display: flex; gap: 4px; background: var(--bg-main); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tab-btn {
    flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-secondary);
    border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: 0.2s;
}
.tab-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 30px; }
.btn-text { background: none; border: none; color: var(--text-secondary); font-weight: 600; cursor: pointer; }
.btn-text:hover { color: var(--text-primary); }
.btn-text.delete:hover { color: var(--danger); }
.spacer { flex: 1; }

.toast {
    position: fixed; bottom: 40px; left: 50%; transform: translate(-50%, 50px);
    background: var(--surface); color: var(--text-primary); padding: 12px 24px; border-radius: 50px;
    box-shadow: var(--shadow); border: 1px solid var(--glass-border); display: flex; align-items: center; gap: 10px;
    font-weight: 600; opacity: 0; pointer-events: none; transition: 0.4s var(--ease); z-index: 2000;
}
.toast.active { transform: translate(-50%, 0); opacity: 1; }
.toast i { color: #32D74B; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }