/* ==========================================================================
   Todo App - Dark Theme
   System fonts only, no external resources
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --bg-surface: #1a1d27;
    --bg-elevated: #232736;
    --border: #2e3348;
    --text: #e4e6f0;
    --text-muted: #8b8fa3;
    --text-faint: #5a5e72;
    --primary: #4a90d9;
    --primary-hover: #5a9fe8;
    --primary-faint: rgba(74, 144, 217, 0.12);
    --danger: #e74c5e;
    --danger-hover: #f05d6e;
    --success: #47c97a;
    --success-hover: #3db86c;
    --warning: #f0a030;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.2);
    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* --- Login --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 26px;
    margin-bottom: 4px;
    text-align: center;
    font-weight: 700;
}

.login-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
    font-size: 14px;
}

.error-message {
    background: rgba(231, 76, 94, 0.12);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 94, 0.25);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-faint);
}

.form-group input[type="date"],
.form-group input[type="time"] {
    color: var(--text-faint);
}

.form-group input[type="date"].has-value,
.form-group input[type="time"].has-value {
    color: var(--text);
    border-color: var(--primary);
    background: var(--primary-faint);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-group input[type="color"] {
    width: 50px;
    height: 36px;
    padding: 2px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s ease;
    font-family: inherit;
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 14px;
}
.btn-ghost:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.btn-icon:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* --- App Layout --- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

#sidebar-close {
    display: none;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.nav-item:hover, .nav-item.active {
    color: var(--text);
    background: var(--bg-elevated);
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item .item-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-faint);
    background: var(--bg-elevated);
    padding: 1px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.sidebar-section {
    padding: 8px 0;
    border-top: 1px solid var(--border);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
}

.sidebar-section-header h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-faint);
    letter-spacing: 1px;
    font-weight: 700;
}

.sidebar-section-header .btn-icon {
    font-size: 18px;
    padding: 2px 6px;
    color: var(--text-faint);
}

.sidebar-section-header .btn-icon:hover {
    color: var(--text);
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-footer .user-info {
    font-size: 13px;
    color: var(--text-muted);
}

.sidebar-footer .logout-link {
    font-size: 12px;
    color: var(--text-faint);
    cursor: pointer;
    transition: color var(--transition);
    text-decoration: none;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.sidebar-footer .logout-link:hover {
    color: var(--text);
}

.list-item, .tag-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 20px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.list-item:hover, .tag-item:hover,
.list-item.active, .tag-item.active {
    color: var(--text);
    background: var(--bg-elevated);
}

.list-dot, .tag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-faint);
}

/* --- Context Menu Trigger Button --- */
.context-menu-btn {
    margin-left: auto;
    font-size: 16px;
    padding: 2px 5px;
    color: var(--text-muted);
    flex-shrink: 0;
    line-height: 1;
}

.list-item:hover .list-item-count {
    display: none;
}

.context-menu-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

/* --- Context Menu Popup --- */
.context-menu {
    position: fixed;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    min-width: 140px;
    padding: 4px 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.context-menu-item-danger {
    color: var(--danger);
}

.context-menu-item-danger:hover {
    background: rgba(231, 76, 94, 0.1);
}

.context-menu-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.main-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.main-header h1 {
    font-size: 22px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-header .list-color-bar {
    width: 4px;
    height: 28px;
    border-radius: 2px;
    flex-shrink: 0;
}

#sidebar-open {
    display: none;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

/* --- Search Bar --- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 30px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.search-icon {
    font-size: 15px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.search-bar input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
}

.search-bar input[type="text"]::placeholder {
    color: var(--text-faint);
}

.search-clear {
    display: none;
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    line-height: 1;
}

.search-clear:hover {
    color: var(--text);
}

.search-clear.visible {
    display: block;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 30px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-wrap: wrap;
}

.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
    margin-right: 4px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    font-family: inherit;
}

.filter-tag:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-tag.active {
    color: #fff;
    border-color: transparent;
}

.filter-tag .remove-filter {
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
}

/* --- Todo Add Form --- */
.todo-add-bar {
    padding: 16px 30px 0;
}

.todo-add-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), border-style var(--transition);
}

.todo-add-form:focus-within {
    border-color: var(--primary);
    border-style: solid;
}

.todo-add-form .add-icon {
    font-size: 20px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.todo-add-form input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
}

.todo-add-form input[type="text"]::placeholder {
    color: var(--text-faint);
}

.todo-add-form .btn {
    flex-shrink: 0;
}

/* --- Todo List --- */
.todo-list-container {
    padding: 16px 30px;
    flex: 1;
    overflow-y: auto;
}

.todo-count-summary {
    font-size: 12px;
    color: var(--text-faint);
    padding-bottom: 12px;
}

.todo-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.todo-item:hover {
    border-color: var(--text-faint);
}

.overdue-mark {
    color: var(--danger);
    font-weight: 800;
}

.todo-item.overdue {
    border-color: var(--danger);
    background: rgba(231, 76, 94, 0.06);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin-top: 1px;
    background: transparent;
}

.todo-checkbox:hover {
    border-color: var(--primary);
}

.todo-item.completed .todo-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.todo-item.completed .todo-checkbox::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.todo-body {
    flex: 1;
    min-width: 0;
}

.todo-title {
    font-size: 15px;
    font-weight: 500;
    word-break: break-word;
}

.todo-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-word;
}

.todo-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.todo-tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.todo-due {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}

.todo-due.overdue {
    color: var(--danger);
}

.todo-due.today {
    color: var(--warning);
}

.todo-list-badge {
    font-size: 11px;
    color: var(--text-faint);
    display: flex;
    align-items: center;
    gap: 4px;
}

.todo-list-badge .list-dot {
    width: 8px;
    height: 8px;
}

.todo-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.todo-actions .btn-icon {
    font-size: 15px;
    padding: 4px 6px;
}

.todo-actions .edit-todo-btn {
    color: var(--primary);
}

.todo-actions .edit-todo-btn:hover {
    color: var(--primary-hover);
    background: var(--primary-faint);
}

.todo-actions .delete-todo-btn {
    color: var(--danger);
}

.todo-actions .delete-todo-btn:hover {
    color: var(--danger-hover);
    background: rgba(231, 76, 94, 0.12);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-faint);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 360px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-header .btn-icon {
    font-size: 20px;
}

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

/* --- Tag checkboxes in modal --- */
.tag-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
    user-select: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
}

.tag-checkbox:hover {
    border-color: var(--primary);
}

.tag-checkbox.selected {
    border-color: var(--primary);
    background: var(--primary-faint);
    color: var(--text);
}

.tag-checkbox .tag-dot {
    width: 8px;
    height: 8px;
}

/* --- Color picker --- */
.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition);
}

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

.color-option.selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg-surface);
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: toast-in 0.3s ease;
    max-width: 340px;
}

.toast.error {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.toast.success {
    border-color: var(--success);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbar --- */
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
.todo-list-container::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track,
.todo-list-container::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

.todo-list-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

/* --- Inline editing in sidebar --- */
.inline-edit-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    outline: none;
    font-family: inherit;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 50;
        transition: left 0.3s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        left: 0;
    }

    #sidebar-close {
        display: block;
    }

    #sidebar-open {
        display: block;
    }

    .main-header {
        padding: 16px 20px;
    }

    .search-bar {
        padding: 10px 20px;
    }

    .filter-bar {
        padding: 10px 20px;
    }

    .todo-add-bar {
        padding: 12px 20px 0;
    }

    .todo-list-container {
        padding: 12px 20px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (min-width: 769px) {
    #sidebar-open {
        display: none !important;
    }
}

/* --- Estimated Time Badge --- */
.todo-est-time {
    font-size: 11px;
    color: var(--text-faint);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* --- AI Chat Panel --- */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 90;
    transition: all var(--transition);
    font-family: inherit;
}

.chat-fab:hover {
    background: var(--primary-hover);
    transform: scale(1.08);
}

.chat-fab.hidden {
    display: none;
}

.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 95;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel.open {
    display: flex;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.chat-header-title {
    font-size: 14px;
    font-weight: 700;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    min-height: 200px;
}

.chat-message {
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-message.user .chat-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.chat-message.assistant .chat-bubble {
    background: var(--bg-elevated);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { font-weight: 600; }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0; padding-left: 18px; }
.chat-bubble li { margin-bottom: 2px; }
.chat-bubble code {
    background: rgba(255,255,255,0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

.chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border-bottom-left-radius: 2px;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
    animation: chat-dot 1.4s infinite ease-in-out both;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes chat-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

.chat-input-area input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.chat-input-area input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-faint);
}

.chat-input-area .btn {
    flex-shrink: 0;
    padding: 8px 12px;
}

@media (max-width: 768px) {
    .chat-panel {
        width: calc(100% - 32px);
        bottom: 16px;
        right: 16px;
        max-height: 60vh;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
    }
}

/* --- Utility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

.hidden {
    display: none !important;
}

/* --- Shared Lists --- */
.shared-indicator {
    font-size: 12px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.6;
}

.shared-list .shared-indicator {
    display: inline;
}

.list-item:hover .shared-indicator {
    display: none;
}

.share-current-section {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.share-section-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-faint);
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 10px;
}

.share-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.share-user {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

.share-perm {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.share-item .btn-icon {
    font-size: 16px;
    padding: 2px 5px;
    color: var(--text-faint);
}

.share-item .btn-icon:hover {
    color: var(--danger);
}

.share-empty {
    font-size: 13px;
    color: var(--text-faint);
    padding: 8px 0;
}

/* --- Notification Bell --- */
.notification-bell-wrapper {
    position: relative;
    display: inline-flex;
}

.notification-bell-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    line-height: 1;
}

.notification-bell-btn:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.notification-badge.visible {
    display: flex;
}

/* --- Notification Panel --- */
.notification-panel {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 50;
    display: none;
    flex-direction: column;
    margin-top: 8px;
    overflow: hidden;
}

.notification-panel.open {
    display: flex;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.notification-panel-header h3 {
    font-size: 15px;
    font-weight: 700;
}

.notification-panel-header .btn-ghost {
    font-size: 12px;
    padding: 4px 8px;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    max-height: 340px;
}

.notification-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.notification-item:hover {
    background: var(--bg-elevated);
}

.notification-item.unread {
    background: var(--primary-faint);
}

.notification-item.unread:hover {
    background: rgba(74, 144, 217, 0.18);
}

.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    background: var(--bg-elevated);
}

.notification-body {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}

.notification-time {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
}

.notification-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition);
    line-height: 1;
}

.notification-item:hover .notification-dismiss {
    opacity: 1;
}

.notification-dismiss:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.notification-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
}

.notification-panel-footer {
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    justify-content: center;
}

.notification-panel-footer .btn-ghost {
    font-size: 12px;
    padding: 4px 8px;
}

/* --- Notification Preferences Modal Toggle --- */
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text);
}

.toggle-label input[type="checkbox"] {
    width: 36px;
    height: 20px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
    margin-left: 12px;
}

.toggle-label input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
}

.toggle-label input[type="checkbox"]:checked {
    background: var(--primary);
}

.toggle-label input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}

.notification-list::-webkit-scrollbar {
    width: 5px;
}

.notification-list::-webkit-scrollbar-track {
    background: transparent;
}

.notification-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

@media (max-width: 768px) {
    .notification-panel {
        position: fixed;
        top: auto;
        left: 16px;
        right: 16px;
        width: auto;
        margin-top: 0;
    }
}

/* --- Priority Dot --- */
.todo-priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.todo-priority-dot.priority-low {
    background: #47c97a;
}

.todo-priority-dot.priority-medium {
    background: #f0a030;
}

.todo-priority-dot.priority-high {
    background: #e74c5e;
}

.todo-priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

/* --- Calendar View --- */
.calendar-container {
    padding: 16px 30px;
    flex: 1;
    overflow-y: auto;
}

.calendar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.calendar-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    min-width: 180px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-dow {
    background: var(--bg-elevated);
    padding: 8px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-faint);
    letter-spacing: 0.5px;
}

.calendar-day {
    background: var(--bg-surface);
    min-height: 100px;
    padding: 6px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}

.calendar-day:hover {
    background: var(--bg-elevated);
}

.calendar-day.other-month {
    opacity: 0.35;
}

.calendar-day-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendar-day.today .calendar-day-number {
    background: var(--primary);
    color: #fff;
}

.calendar-day-todos {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-todo-item {
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid var(--text-faint);
}

.calendar-todo-item.priority-high {
    border-left-color: #e74c5e;
}

.calendar-todo-item.priority-medium {
    border-left-color: #f0a030;
}

.calendar-todo-item.priority-low {
    border-left-color: #47c97a;
}

.calendar-todo-item.completed-todo {
    text-decoration: line-through;
    opacity: 0.5;
}

.calendar-more {
    font-size: 10px;
    color: var(--text-faint);
    padding: 1px 4px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .calendar-container {
        padding: 12px 10px;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .calendar-day-number {
        font-size: 11px;
        width: 22px;
        height: 22px;
    }

    .calendar-todo-item {
        font-size: 10px;
    }

    .calendar-header h2 {
        font-size: 15px;
        min-width: 140px;
    }
}

/* --- Recurring Todo Badge --- */
.todo-recurrence-badge {
    font-size: 11px;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
}

.notification-summary {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-top: 12px;
    display: none;
    flex-direction: column;
    gap: 4px;
}

.notification-summary.visible {
    display: flex;
}

.notification-summary-title {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.notification-summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.notification-summary-icon {
    flex-shrink: 0;
}

.todo-pushover-badge {
    font-size: 11px;
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
}

/* --- Subtasks --- */
.subtask-list {
    margin-left: 34px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.todo-item-subtask {
    padding: 8px 12px;
    border-color: transparent;
    background: transparent;
}

.todo-item-subtask:hover {
    background: var(--bg-surface);
    border-color: var(--border);
}

.todo-item-subtask .todo-checkbox {
    width: 18px;
    height: 18px;
}

.todo-item-subtask .todo-title {
    font-size: 14px;
}

.subtask-progress {
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 600;
}

.subtask-toggle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-family: inherit;
    transition: all var(--transition);
}

.subtask-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.subtask-toggle-arrow {
    display: inline-block;
    font-size: 8px;
    transition: transform var(--transition);
}

.subtask-toggle-arrow.expanded {
    transform: rotate(90deg);
}

.subtask-list.collapsed {
    display: none;
}

.subtask-add {
    padding: 2px 0;
}

.subtask-add-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.subtask-add-input::placeholder {
    color: var(--text-faint);
}

.subtask-add-input:focus {
    border-color: var(--primary);
    border-style: solid;
}

.subtask-add {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.todo-item:hover + .subtask-list .subtask-add,
.subtask-list:hover .subtask-add,
.subtask-add:focus-within {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .subtask-list {
        margin-left: 24px;
    }
    .subtask-add {
        opacity: 1;
        pointer-events: auto;
    }
}
