:root[data-theme="dark"] {
    --bg-color: #0d0e15;
    --sidebar-bg: rgba(13, 14, 21, 0.8);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover: rgba(255, 255, 255, 0.06);
    --text-primary: #ffffff;
    --text-secondary: #8b92a5;
    --accent: #4facfe;
    --accent-glow: rgba(79, 172, 254, 0.3);
    --blob-1: rgba(0, 242, 254, 0.15);
    --blob-2: rgba(142, 45, 226, 0.15);
    --blob-3: rgba(255, 117, 140, 0.15);
    --input-bg: rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] {
    --bg-color: #f3f4f6;
    --sidebar-bg: rgba(243, 244, 246, 0.9);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.05);
    --card-hover: rgba(255, 255, 255, 0.9);
    --text-primary: #1a1b20;
    --text-secondary: #5f6368;
    --accent: #0093E9;
    --accent-glow: rgba(0, 147, 233, 0.3);
    --blob-1: rgba(0, 147, 233, 0.15);
    --blob-2: rgba(142, 45, 226, 0.15);
    --blob-3: rgba(255, 117, 140, 0.15);
    --input-bg: rgba(0, 0, 0, 0.02);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden; /* App feels like a native desktop app */
    transition: background-color 0.4s ease;
}

/* Ambient Background Blobs */
.ambient-background {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    animation: drift 25s infinite ease-in-out alternate;
}

.blob-1 { width: 500px; height: 500px; background: var(--blob-1); top: -100px; left: -100px; }
.blob-2 { width: 600px; height: 600px; background: var(--blob-2); bottom: -200px; right: -100px; animation-delay: -5s; }
.blob-3 { width: 400px; height: 400px; background: var(--blob-3); top: 30%; left: 40%; animation-delay: -10s; }

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(150px, 100px) scale(1.2); }
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 50px;
    padding: 0 10px;
}

.logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--accent) 0%, #80D0C7 100%);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    color: white;
}

.logo h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 20px;
    border-radius: 15px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.nav-item i {
    font-size: 1.3rem;
}

.nav-item:hover {
    background: var(--card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 20px;
    border-radius: 15px;
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    margin-top: auto;
}

.theme-btn:hover {
    background: var(--card-hover);
}

.theme-btn i {
    font-size: 1.3rem;
}

/* Main Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Top Bar */
.top-bar {
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-box i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.search-box input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.avatar {
    width: 45px; height: 45px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
}

/* Create Note Box */
.create-note-section {
    padding: 0 40px 30px;
    display: flex;
    justify-content: center;
}

.create-note-box {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.create-note-box input, 
.create-note-box textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
}

.create-note-box input {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: none; /* Shown on focus */
}

.create-note-box textarea {
    font-size: 1rem;
    resize: none;
    height: 40px; /* Expands on focus */
}

.note-actions {
    display: none; /* Shown on focus */
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--card-border);
}

.create-note-box.expanded input { display: block; }
.create-note-box.expanded textarea { height: 100px; }
.create-note-box.expanded .note-actions { display: flex; }

.color-picker {
    display: flex;
    gap: 8px;
}

.color-btn {
    width: 25px; height: 25px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-btn.active {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.create-note-box select {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 8px;
    outline: none;
}

.save-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}
.save-btn:hover { background: #3b82f6; }

.cancel-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 8px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}
.cancel-btn:hover { background: var(--card-hover); color: var(--text-primary); }

/* Notes Grid (Masonry like) */
.notes-grid {
    padding: 0 40px 40px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    overflow-y: auto;
    align-items: start;
}

/* Custom Scrollbar */
.notes-grid::-webkit-scrollbar { width: 8px; }
.notes-grid::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 10px; }

.note-card {
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(15px);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: zoomIn 0.4s ease forwards;
}

.note-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
    border-color: var(--accent);
}

.note-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.note-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    white-space: pre-wrap;
    /* truncate if too long */
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

.note-category {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    padding: 4px 10px;
    border-radius: 8px;
    color: var(--text-primary);
}

.delete-note-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.note-card:hover .delete-note-btn { opacity: 1; }
.delete-note-btn:hover { color: #ff1744; transform: scale(1.1); }

/* Edit Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-overlay .modal-content {
    width: 100%;
    max-width: 600px;
    margin: 20px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-overlay .note-actions { display: flex; }
.modal-overlay input { display: block; }
.modal-overlay textarea { height: 150px; }

/* Animations */
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideOut {
    to { opacity: 0; transform: scale(0.9); }
}

/* Responsive */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--card-border); padding: 15px; }
    .logo { margin-bottom: 15px; }
    .nav-links { flex-direction: row; overflow-x: auto; padding-bottom: 10px; }
    .nav-item { padding: 8px 12px; white-space: nowrap; }
    .theme-btn { display: none; /* Hide or move for mobile */ }
    .main-area { height: calc(100vh - 140px); }
    .top-bar { padding: 20px; }
    .create-note-section { padding: 0 20px 20px; }
    .notes-grid { padding: 0 20px 20px; }
}
