:root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --surface-hover: #f5f0e8;
    --primary: #d4b8a0;
    --primary-hover: #c4a88e;
    --text: #5c4b3e;
    --text-light: #8a7a6a;
    --border: #ece5db;
    --shadow: 0 4px 20px rgba(92, 75, 62, 0.06);
    --shadow-strong: 0 8px 30px rgba(92, 75, 62, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --success: #a8d5a2;
    --warning: #f0d4a8;
    --danger: #e8a8a8;
    --info: #a8c8e8;
}

[data-theme="dark"] {
    --bg: #2b2723;
    --surface: #3a3530;
    --surface-hover: #4a443d;
    --primary: #c4a88e;
    --primary-hover: #d4b8a0;
    --text: #e8ddd0;
    --text-light: #b0a594;
    --border: #4a443d;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-strong: 0 8px 30px rgba(0, 0, 0, 0.3);
    --success: #7ab576;
    --warning: #d4b070;
    --danger: #c07070;
    --info: #7a9ec8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.animate-fade {
    animation: fadeIn 0.5s ease both;
}

.animate-slide {
    animation: slideIn 0.4s ease both;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 32px;
    padding: 0 8px;
}

.brand-icon {
    font-size: 1.6rem;
}

.sidebar-menu {
    list-style: none;
    flex: 1;
}

.sidebar-menu li {
    margin-bottom: 6px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-menu .icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-badge {
    font-size: 0.9rem;
    color: var(--text-light);
    padding: 0 8px;
}

.logout-link {
    font-size: 0.85rem;
    color: var(--primary-hover);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.logout-link:hover {
    background: var(--surface-hover);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
    user-select: none;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Main content */
.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px;
    max-width: calc(100% - 240px);
    animation: fadeIn 0.4s ease;
}

/* Auth layout */
.auth-layout {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    animation: fadeIn 0.5s ease;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s, background 0.3s, border-color 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-strong);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Login */
.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box .brand-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    display: block;
}

.login-box h1 {
    font-size: 1.6rem;
    margin-bottom: 24px;
    color: var(--text);
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 184, 160, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-secondary:hover {
    background: #ebe5dc;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #5a544d;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #d89090;
}

[data-theme="dark"] .btn-danger:hover {
    background: #a06060;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* Flash messages */
.flash-container {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.flash-error {
    background: #fce8e8;
    color: #a05050;
    border: 1px solid #f0cccc;
}

.flash-success {
    background: #e8f5e8;
    color: #508050;
    border: 1px solid #cce0cc;
}

[data-theme="dark"] .flash-error {
    background: #4a3030;
    color: #e8b0b0;
    border-color: #5a4040;
}

[data-theme="dark"] .flash-success {
    background: #304a30;
    color: #b0e8b0;
    border-color: #405a40;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dashboard-grid .card {
    min-height: 300px;
}

.widget-list {
    list-style: none;
}

.widget-list li {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    margin-bottom: 10px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.15s;
}

.widget-list li:hover {
    transform: translateX(4px);
}

.widget-list li .meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* Weather widget */
.weather-widget {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

.weather-icon {
    font-size: 3rem;
}

.weather-info h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.weather-info p {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-layers {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.layer-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    user-select: none;
}

.layer-badge:hover {
    transform: scale(1.05);
}

.layer-badge.inactive {
    opacity: 0.4;
}

.layer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day-label {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    padding: 8px 0;
}

.calendar-day {
    aspect-ratio: 1;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 8px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 80px;
}

.calendar-day:hover {
    background: var(--surface-hover);
    transform: scale(1.02);
}

.calendar-day.today {
    border-color: var(--primary);
    background: rgba(212, 184, 160, 0.08);
}

.calendar-day .day-number {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.calendar-day.today .day-number {
    color: var(--primary-hover);
}

.calendar-day .events-mini {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    width: 100%;
}

.calendar-day .event-pill {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    color: #1a120b;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(92, 75, 62, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-strong);
    border: 1px solid var(--border);
    transform: translateY(10px);
    transition: transform 0.2s;
}

.modal-overlay.open .modal-box {
    transform: translateY(0);
}

.modal-box h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Notes */
.notes-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.notes-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--surface-hover);
    color: var(--text-light);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.filter-badge:hover,
.filter-badge.active {
    background: var(--primary);
    color: #fff;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.note-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
    position: relative;
    animation: fadeIn 0.4s ease both;
}

.note-card:hover {
    box-shadow: var(--shadow-strong);
    transform: translateY(-2px);
}

.note-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
    word-break: break-word;
    color: var(--text);
}

.note-card p {
    font-size: 0.9rem;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-card .note-date {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 12px;
}

.note-card .note-category {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--surface-hover);
    color: var(--text-light);
    margin-top: 8px;
}

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

.color-option {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: var(--text);
}

/* Tasks */
.tasks-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.tasks-filters {
    display: flex;
    gap: 8px;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    animation: fadeIn 0.3s ease both;
    cursor: pointer;
}

.task-item:hover {
    box-shadow: var(--shadow-strong);
    transform: translateX(4px);
}

.task-item.done {
    opacity: 0.6;
}

.task-item.done .task-title {
    text-decoration: line-through;
    color: var(--text-light);
}

.task-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.task-checkbox:hover {
    background: var(--primary);
}

.task-checkbox.checked {
    background: var(--primary);
    color: #fff;
}

.task-content {
    flex: 1;
}

.task-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 2px;
}

.task-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.priority-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.priority-high {
    background: var(--danger);
    color: #fff;
}

.priority-medium {
    background: var(--warning);
    color: var(--text);
}

.priority-low {
    background: var(--success);
    color: var(--text);
}

/* Bookmarks */
.bookmarks-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.bookmark-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    animation: fadeIn 0.4s ease both;
}

.bookmark-card:hover {
    box-shadow: var(--shadow-strong);
    transform: translateY(-4px);
}

.bookmark-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.bookmark-title {
    font-weight: 700;
    font-size: 0.95rem;
    word-break: break-word;
}

.bookmark-url {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
    word-break: break-all;
}

.dashboard-grid .card {
    transition: transform 0.15s, box-shadow 0.2s;
}
.dashboard-edit .card {
    border: 2px dashed var(--primary);
    position: relative;
}
.dashboard-edit .card::after {
    content: '⋮⋮';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 1rem;
    color: var(--primary);
    opacity: 0.6;
}

.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
    }
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 16px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .calendar-grid {
        gap: 4px;
    }
    .calendar-day {
        min-height: 50px;
        padding: 4px;
    }
    .tasks-toolbar,
    .notes-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Sidebar dropdown */
.sidebar-menu .dropdown {
    position: relative;
}

.sidebar-menu .dropdown-toggle {
    justify-content: space-between;
}

.sidebar-menu .dropdown-menu {
    list-style: none;
    padding-left: 12px;
    margin-top: 4px;
    display: none;
    animation: fadeIn 0.2s ease;
}

.sidebar-menu .dropdown.open .dropdown-menu {
    display: block;
}

.sidebar-menu .dropdown.open .chevron {
    transform: rotate(180deg);
}

.sidebar-menu .dropdown-menu li {
    margin-bottom: 4px;
}

.sidebar-menu .dropdown-menu a {
    font-size: 0.9rem;
    padding: 8px 10px;
}

/* Folder link breadcrumb */
.folder-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.folder-link:hover {
    background: var(--primary);
    color: #fff;
}

/* Stars */
.stars {
    font-size: 0.9rem;
    letter-spacing: 2px;
}

