/* Second Brain v2 — styles (extracted from index.html, v2.3 phase 0) */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            /* Display settings (v2.3 phase 2 — Aa popover, persisted) */
            --content-font-size: 13px;
            --content-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            --content-line-height: 1.8;
            --item-pad: 8px;

            --primary: #667eea;
            --secondary: #764ba2;
            --bg-dark: #0f1419;
            --bg-darker: #0a0d14;
            --bg-card: #1a1f2e;
            --border: #2d3748;
            --text: #e1e8ed;
            --text-muted: #8892b0;
            --success: #43e97b;
            --warning: #fa709a;
            --info: #00f2fe;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg-dark);
            color: var(--text);
            overflow: hidden;
        }

        .app-container {
            display: grid;
            /* --brain-w: adjustable Ask Brain panel width (drag handle, persisted) */
            grid-template-columns: 290px 1fr var(--brain-w, 350px);
            grid-template-rows: 70px auto 1fr;
            height: 100vh;
            gap: 1px;
            background: var(--border);
        }

        /* ===== HEADER ===== */
        header {
            grid-column: 1 / -1;
            background: var(--bg-card);
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 30px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
            gap: 30px;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .logo {
            font-size: 18px;
            font-weight: 700;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
        }

        .logo-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--primary);
        }

        .search-box {
            flex: 1;
            min-width: 300px;
            position: relative;
        }

        .search-box input {
            width: 100%;
            padding: 12px 16px 12px 40px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 14px;
        }

        .search-box input::placeholder {
            color: var(--text-muted);
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .search-icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header-icon-btn {
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.2s;
        }

        .header-icon-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .header-icon-btn.active {
            background: var(--primary);
            border-color: var(--primary);
            color: white;
        }

        .theme-toggle {
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.2s;
        }

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

        /* ===== DASHBOARD CARDS ===== */
        .dashboard {
            grid-column: 2 / 4;
            grid-row: 2;
            background: var(--bg-dark);
            border-bottom: 1px solid var(--border);
            padding: 8px 30px;
            display: flex;
            gap: 8px;
            overflow-x: auto;
            align-items: center;
        }

        /* Compact horizontal stat chips */
        .stat-card {
            display: flex;
            align-items: center;
            gap: 7px;
            padding: 5px 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 16px;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }

        .stat-card:hover {
            background: rgba(102, 126, 234, 0.05);
            border-color: var(--primary);
        }

        .stat-icon {
            font-size: 13px;
        }

        .stat-number {
            font-size: 13px;
            font-weight: 700;
            color: var(--primary);
        }

        .stat-label {
            font-size: 10px;
            color: var(--text-muted);
            text-transform: uppercase;
        }

        /* ===== SIDEBAR ===== */
        .sidebar {
            grid-row: 2 / 4;
            grid-column: 1;
            background: var(--bg-darker);
            border-right: 1px solid var(--border);
            overflow-y: auto;
            padding: 20px 15px;
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .sidebar-section {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        /* Quick action buttons row */
        .sidebar-quick-actions {
            display: flex;
            gap: 6px;
        }

        .sidebar-quick-actions button {
            flex: 1;
            padding: 10px 6px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }

        .sidebar-quick-actions button:hover,
        .sidebar-quick-actions button.active {
            border-color: var(--primary);
            color: var(--primary);
        }

        /* Calendar widget (P2a) */
        .cal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
            font-size: 12px;
            font-weight: 700;
        }

        .cal-header button {
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text);
            border-radius: 4px;
            width: 24px;
            height: 24px;
            cursor: pointer;
            font-size: 14px;
        }

        .cal-header button:hover { border-color: var(--primary); color: var(--primary); }

        .cal-grid {
            display: grid;
            /* week-number column + 7 days */
            grid-template-columns: 20px repeat(7, 1fr);
            gap: 2px;
        }

        .cal-week {
            font-size: 9px;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            justify-content: center;
            border-right: 1px solid var(--border);
        }

        .cal-dow div {
            text-align: center;
            font-size: 9px;
            color: var(--text-muted);
            padding: 2px 0;
        }

        .cal-day {
            text-align: center;
            font-size: 11px;
            padding: 4px 0 2px 0;
            border-radius: 4px;
            cursor: pointer;
            border: 1px solid transparent;
            min-height: 28px;
        }

        .cal-day:hover { background: rgba(102, 126, 234, 0.12); }

        .cal-day.today {
            border-color: var(--primary);
            font-weight: 700;
            color: var(--primary);
        }

        .cal-day.has-daily { background: rgba(102, 126, 234, 0.15); }

        .cal-dots {
            display: flex;
            justify-content: center;
            gap: 2px;
            height: 5px;
            margin-top: 1px;
        }

        .cal-dot {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: var(--info);
        }

        .cal-dot.due { background: var(--warning); }

        /* Sidebar search */
        .sidebar-search {
            width: 100%;
            padding: 11px 14px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 13px;
        }

        .sidebar-search::placeholder { color: var(--text-muted); }

        .sidebar-search:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        /* Quick create form */
        .quick-create-form {
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding: 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
        }

        .quick-create-form.collapsed { display: none; }

        .quick-create-form input,
        .quick-create-form select,
        .quick-create-form textarea {
            width: 100%;
            padding: 10px 12px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 13px;
            font-family: inherit;
        }

        .quick-create-form textarea {
            min-height: 90px;
            resize: vertical;
            font-family: monospace;
        }

        .quick-create-form input:focus,
        .quick-create-form select:focus,
        .quick-create-form textarea:focus {
            outline: none;
            border-color: var(--primary);
        }

        .quick-create-form input::placeholder,
        .quick-create-form textarea::placeholder { color: var(--text-muted); }

        .quick-create-form .qc-save {
            padding: 12px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
        }

        .quick-create-form .qc-save:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
        }

        .sidebar-title {
            font-size: 11px;
            font-weight: 700;
            text-transform: uppercase;
            color: var(--text-muted);
            padding: 0 8px;
        }

        /* Quick Access Items */
        .quick-item {
            padding: 10px 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .quick-item:hover {
            background: rgba(102, 126, 234, 0.1);
            border-color: var(--primary);
        }

        .quick-item.active {
            background: var(--primary);
            border-color: var(--primary);
            font-weight: 600;
        }

        .quick-item-icon {
            flex-shrink: 0;
            font-size: 14px;
        }

        /* Category Pills */
        .category-filters {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .category-pill {
            padding: 8px 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .category-pill:hover {
            background: rgba(102, 126, 234, 0.05);
            border-color: var(--primary);
        }

        .category-pill.active {
            background: var(--primary);
            border-color: var(--primary);
            color: white;
            font-weight: 600;
        }

        .category-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
        }

        /* Tags Input */
        .tags-input {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 12px;
        }

        .tags-input::placeholder {
            color: var(--text-muted);
        }

        .tags-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        /* Action Buttons */
        .sidebar-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-top: auto;
        }

        .sidebar-actions button {
            padding: 12px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: all 0.2s;
        }

        .sidebar-actions button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        .sidebar-actions button.secondary {
            background: var(--bg-card);
            color: var(--text);
            border: 1px solid var(--border);
        }

        .sidebar-actions button.secondary:hover {
            border-color: var(--primary);
        }

        /* ===== MAIN CONTENT ===== */
        .main-content {
            grid-row: 3;
            grid-column: 2 / 4;
            background: var(--bg-dark);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* When brain panel is open, shrink dashboard + main content to column 2 */
        .app-container.panel-open .main-content {
            grid-column: 2;
            border-right: 1px solid var(--border);
        }

        .app-container.panel-open .dashboard {
            grid-column: 2;
        }

        /* Sidebar hidden (Cmd+[) — collapse column 1, content takes full width */
        .app-container.sidebar-hidden {
            grid-template-columns: 0 1fr var(--brain-w, 350px);
        }

        .app-container.sidebar-hidden .sidebar {
            display: none;
        }

        /* Tab Navigation - Hidden */
        .content-tabs {
            display: none;
        }

        .content-tab {
            display: none;
        }

        /* Content Area - Graph Only */
        .content-area {
            flex: 1;
            overflow: hidden;
            padding: 0;
        }

        .tab-content {
            display: none;
            width: 100%;
            height: 100%;
            padding: 0;
        }

        .tab-content.active {
            display: flex;
            flex-direction: column;
        }

        #graphTab {
            display: flex !important;
            padding: 0;
        }

        #notesTab {
            display: none;
            padding: 20px 30px;
        }

        #queryTab {
            display: none;
            padding: 20px 30px;
        }

        #graphContainer {
            width: 100%;
            height: 100%;
            position: relative;
        }

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

        .note-card {
            padding: 16px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .note-card:hover {
            background: rgba(102, 126, 234, 0.05);
            border-color: var(--primary);
        }

        .note-card.active {
            background: rgba(102, 126, 234, 0.1);
            border-color: var(--primary);
        }

        .note-title {
            font-weight: 600;
            font-size: 14px;
            margin-bottom: 6px;
        }

        .note-meta {
            display: flex;
            gap: 10px;
            font-size: 11px;
            color: var(--text-muted);
        }

        .brain-query-form {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .brain-query-textarea {
            width: 100%;
            padding: 12px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 13px;
            font-family: inherit;
            resize: vertical;
            min-height: 100px;
            max-height: 200px;
        }

        .brain-query-textarea::placeholder {
            color: var(--text-muted);
        }

        .brain-query-textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .brain-query-submit {
            padding: 12px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.2s;
        }

        .brain-query-submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        .brain-answer {
            padding: 14px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            line-height: 1.8;
            font-size: 13px;
        }

        .brain-sources {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .brain-source {
            padding: 10px 12px;
            background: var(--bg-card);
            border-left: 3px solid var(--primary);
            border-radius: 4px;
            font-size: 12px;
        }

        /* ===== RIGHT PANEL - Brain Query ===== */
        .right-panel {
            grid-row: 2 / 4;
            grid-column: 3;
            background: var(--bg-card);
            border-left: 1px solid var(--border);
            overflow-y: auto;
            padding: 15px;
            display: none;
            flex-direction: column;
            gap: 12px;
            min-width: 350px;
        }

        .right-panel.active {
            display: flex;
            position: relative;
        }

        /* Drag handle on the panel's left edge */
        .panel-resize-handle {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 5px;
            cursor: ew-resize;
            z-index: 10;
        }

        .panel-resize-handle:hover,
        .panel-resize-handle.dragging {
            background: var(--primary);
        }

        .brain-source {
            cursor: pointer;
            transition: all 0.15s;
        }

        .brain-source:hover {
            background: rgba(102, 126, 234, 0.12);
            border-left-color: var(--info);
        }

        #brainMicBtn.listening {
            background: var(--warning);
            animation: micPulse 1s infinite;
        }

        @keyframes micPulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(250, 112, 154, 0.6); }
            50% { box-shadow: 0 0 0 8px rgba(250, 112, 154, 0); }
        }

        .right-panel-title {
            font-size: 14px;
            font-weight: 700;
            color: var(--text);
            margin-bottom: 5px;
        }

        .right-panel-subtitle {
            font-size: 11px;
            color: var(--text-muted);
            margin-bottom: 12px;
        }

        .detail-empty {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            min-height: 200px;
            color: var(--text-muted);
            text-align: center;
            font-size: 13px;
        }

        .detail-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }

        .detail-title {
            font-size: 16px;
            font-weight: 700;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .detail-close {
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            width: 28px;
            height: 28px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
            font-size: 16px;
        }

        .detail-close:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .detail-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            font-size: 11px;
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .detail-meta span {
            padding: 3px 6px;
            background: var(--bg-dark);
            border-radius: 3px;
        }

        .detail-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            flex-shrink: 0;
        }

        .detail-tag {
            padding: 3px 8px;
            background: rgba(102, 126, 234, 0.1);
            border: 1px solid rgba(102, 126, 234, 0.3);
            border-radius: 3px;
            font-size: 11px;
            color: var(--primary);
        }

        .detail-content {
            padding: 10px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 4px;
            font-size: 12px;
            line-height: 1.6;
            white-space: pre-wrap;
            word-break: break-word;
            flex: 1;
            overflow-y: auto;
            min-height: 100px;
        }

        .detail-actions {
            display: flex;
            gap: 6px;
            padding-top: 8px;
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }

        .detail-actions button {
            flex: 1;
            padding: 8px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            border-radius: 4px;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.2s;
        }

        .detail-actions button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .detail-actions button.delete:hover {
            border-color: var(--warning);
            color: var(--warning);
        }

        /* ===== MODAL ===== */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: var(--bg-card);
            padding: 30px;
            border-radius: 8px;
            width: 90%;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
        }

        .modal-header {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 20px;
        }

        .form-group {
            margin-bottom: 16px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .form-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
        }

        .form-input, .form-textarea, select.form-input {
            padding: 10px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text);
            font-size: 13px;
            font-family: inherit;
        }

        select.form-input {
            appearance: none;
            padding-right: 30px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 8px center;
            padding-right: 28px;
        }

        select.form-input option {
            background: var(--bg-dark);
            color: var(--text);
        }

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

        .form-input:focus, .form-textarea:focus, select.form-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .modal-buttons {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }

        .modal-buttons button {
            flex: 1;
            padding: 12px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.2s;
        }

        .modal-buttons button.submit {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
        }

        .modal-buttons button.submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        .modal-buttons button.cancel {
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
        }

        .modal-buttons button.cancel:hover {
            border-color: var(--primary);
        }

        /* ===== NOTE DETAIL MODAL ===== */
        .note-detail-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 240px;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.3);
            z-index: 2000;
            align-items: center;
            justify-content: flex-end;
            pointer-events: none;
        }

        .note-detail-modal.active {
            display: flex;
        }

        .note-detail-modal.active .note-detail-panel {
            pointer-events: all;
        }

        .note-detail-panel {
            background: var(--bg-card);
            width: 450px;
            max-width: 90vw;
            height: 100vh;
            overflow-y: auto;
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 15px;
            box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
        }

        .note-detail-header {
            display: flex;
            justify-content: space-between;
            align-items: start;
            gap: 10px;
            flex-shrink: 0;
        }

        .note-detail-title {
            font-size: 18px;
            font-weight: 700;
            flex: 1;
        }

        .note-detail-close {
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            width: 32px;
            height: 32px;
            border-radius: 6px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
            font-size: 18px;
        }

        .note-detail-close:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .note-detail-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            font-size: 12px;
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .note-detail-meta span {
            padding: 4px 8px;
            background: var(--bg-dark);
            border-radius: 4px;
        }

        .note-detail-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            flex-shrink: 0;
        }

        .note-detail-tag {
            padding: 4px 10px;
            background: rgba(102, 126, 234, 0.1);
            border: 1px solid rgba(102, 126, 234, 0.3);
            border-radius: 4px;
            font-size: 12px;
            color: var(--primary);
        }

        .note-detail-body {
            padding: 14px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 13px;
            line-height: 1.8;
            white-space: pre-wrap;
            word-break: break-word;
            flex: 1;
            overflow-y: auto;
        }

        /* Rendered markdown mode (P0 Obsidian Web) */
        .note-detail-body.md-rendered {
            white-space: normal;
        }

        .markdown-body h1, .markdown-body h2, .markdown-body h3,
        .markdown-body h4, .markdown-body h5 {
            margin: 14px 0 8px 0;
            line-height: 1.3;
        }
        .markdown-body h1 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
        .markdown-body h2 { font-size: 16px; }
        .markdown-body h3 { font-size: 14px; }
        .markdown-body p { margin: 8px 0; }
        .markdown-body ul, .markdown-body ol { margin: 8px 0; padding-left: 22px; }
        .markdown-body li { margin: 3px 0; }
        .markdown-body li.task-item { list-style: none; margin-left: -18px; }
        .markdown-body input[type="checkbox"] {
            accent-color: var(--primary);
            margin-right: 6px;
            cursor: pointer;
            width: 14px;
            height: 14px;
        }
        .markdown-body code {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 3px;
            padding: 1px 5px;
            font-size: 12px;
        }
        .markdown-body pre {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 6px;
            padding: 10px;
            overflow-x: auto;
            margin: 8px 0;
        }
        .markdown-body pre code { background: none; border: none; padding: 0; }
        .markdown-body blockquote {
            border-left: 3px solid var(--primary);
            padding: 4px 12px;
            margin: 8px 0;
            color: var(--text-muted);
        }
        .markdown-body table {
            border-collapse: collapse;
            margin: 8px 0;
            width: 100%;
            font-size: 12px;
        }
        .markdown-body th, .markdown-body td {
            border: 1px solid var(--border);
            padding: 6px 10px;
            text-align: left;
        }
        .markdown-body th { background: var(--bg-card); }
        .markdown-body a { color: var(--info); }
        .markdown-body img { max-width: 100%; border-radius: 6px; }
        .markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

        .wikilink {
            color: var(--primary) !important;
            text-decoration: none;
            border-bottom: 1px dashed var(--primary);
            cursor: pointer;
        }
        .wikilink:hover { color: var(--info) !important; border-bottom-color: var(--info); }
        .wikilink-missing {
            color: var(--text-muted);
            border-bottom: 1px dashed var(--text-muted);
        }

        .note-detail-actions {
            display: flex;
            gap: 8px;
            padding-top: 10px;
            border-top: 1px solid var(--border);
            flex-shrink: 0;
        }

        .note-detail-actions button {
            flex: 1;
            padding: 10px;
            background: var(--bg-dark);
            border: 1px solid var(--border);
            color: var(--text);
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: all 0.2s;
        }

        .note-detail-actions button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .note-detail-actions button.delete:hover {
            border-color: var(--warning);
            color: var(--warning);
        }

        /* ===== LOGIN ===== */
        .login-screen {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }

        .login-box {
            background: var(--bg-card);
            padding: 40px;
            border-radius: 8px;
            width: 100%;
            max-width: 400px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
        }

        .login-box h2 {
            margin-bottom: 20px;
            text-align: center;
        }

        .login-box input {
            width: 100%;
            padding: 12px;
            border: 1px solid var(--border);
            border-radius: 6px;
            background: var(--bg-dark);
            color: var(--text);
            font-size: 14px;
            margin-bottom: 15px;
        }

        .login-box input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .login-box button {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .login-box button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        /* ===== SCROLLBAR ===== */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-dark);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--primary);
        }

        @keyframes toastIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* ===== RESPONSIVE ===== */
        @media (max-width: 1200px) {
            .app-container {
                grid-template-columns: 200px 1fr;
            }

            .right-panel {
                min-width: 280px;
            }
        }

        @media (max-width: 900px) {
            .app-container {
                grid-template-columns: 1fr;
            }

            .sidebar {
                display: none;
            }

            .right-panel {
                display: none;
            }
        }

/* ===== Display settings (v2.3 phase 2) ===== */
body.density-compact { --content-line-height: 1.45; --item-pad: 5px; }
body.density-comfort { --content-line-height: 2.05; --item-pad: 12px; }

/* Content areas follow the Aa settings (!important beats inline styles
   in JS-generated markup) */
.note-detail-body, .markdown-body, .brain-answer,
#inlineEditArea, #editContent,
.quick-item, .task-row, .brain-query-textarea {
    font-size: var(--content-font-size) !important;
    font-family: var(--content-font) !important;
    line-height: var(--content-line-height) !important;
}

/* Monospace stays monospace in raw editors when font=mono is NOT chosen?
   No — editors follow the chosen font except explicit code blocks */
.markdown-body code, .markdown-body pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace !important; }

.quick-item, .task-row { padding-top: var(--item-pad); padding-bottom: var(--item-pad); }

/* Aa popover */
.font-popover {
    position: absolute;
    top: 60px;
    right: 20px;
    z-index: 2500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 240px;
}

.fp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 12px;
}

.fp-row > span:first-child { color: var(--text-muted); }

.fp-opts { display: flex; gap: 4px; }

.fp-opts button, .fp-size button {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

.fp-opts button.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
}

.fp-size { display: flex; align-items: center; gap: 8px; }
.fp-size span { min-width: 24px; text-align: center; font-weight: 700; }

/* ===== Center workspace (v2.3 phase 3) ===== */
.center-view {
    display: none;
    width: 100%;
    height: 100%;
}

.center-view.active {
    display: flex;
    flex-direction: column;
}

#noteView { overflow: hidden; }

/* Note reading pane: centered, readable line length like Obsidian */
.note-center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 24px 32px 32px 32px;
    overflow-y: auto;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

/* ===== File tree kiểu Obsidian (v2.3 phase 4) ===== */
.file-tree-wrap {
    flex: 1;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
}

.tree-folder-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
}

.tree-folder-row:hover { background: rgba(102, 126, 234, 0.1); }

.tree-chevron {
    width: 12px;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.15s;
    display: inline-block;
}

.tree-chevron.open { transform: rotate(90deg); }

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

.tree-count {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tree-children {
    margin-left: 11px;
    border-left: 1px solid var(--border);
    padding-left: 8px;
}

.tree-file {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
}

.tree-file:hover { background: rgba(102, 126, 234, 0.1); }

.tree-file.active {
    background: rgba(102, 126, 234, 0.22);
    color: var(--primary);
}

.tree-file-icon { flex-shrink: 0; font-size: 11px; }

.tree-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: 10px;
    text-align: center;
}

/* ===== Local graph (v2.3 phase 4) ===== */
.local-graph {
    flex-shrink: 0;
    height: 190px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
}

.local-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.local-graph-header button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
}

.local-graph-header button:hover { border-color: var(--primary); color: var(--primary); }

#localGraphCanvas {
    flex: 1;
    border-radius: 8px;
    background: var(--bg-card);
    overflow: hidden;
}

/* ===== Right workspace (v2.3 phase 5) ===== */
.ws-top {
    flex: 1 1 55%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.ws-bottom {
    flex: 1 1 45%;
    min-height: 140px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
}

.ws-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.ws-tab {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.ws-tab.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(102, 126, 234, 0.08);
}

.ws-content { display: none; flex: 1; overflow-y: auto; min-height: 0; }
.ws-content.active { display: block; }

.mini-group {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 8px 0 4px 0;
}

.mini-task {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 5px 6px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 5px;
    margin-bottom: 4px;
    font-size: 12px;
}

.mini-task span { cursor: pointer; flex: 1; }
.mini-task span:hover { color: var(--primary); }

/* WYSIWYG edit mode (v2.3) */
#wysiwygArea.wysiwyg-active {
    outline: 1px solid var(--primary);
    cursor: text;
}

#wysiwygArea.wysiwyg-active:focus { outline: 1px solid var(--primary); }

/* Sidebar mini tasks (bottom, replaces local graph) */
.sidebar-tasks {
    flex-shrink: 0;
    max-height: 240px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
}

.sidebar-tasks #miniTasks {
    flex: 1;
    overflow-y: auto;
    min-height: 60px;
}

/* Wide editor mode (↔ toggle) */
.note-center-panel.wide { max-width: 100%; }

/* ===== Note tabs (multi-note) ===== */
.note-tabs {
    display: flex;
    gap: 2px;
    padding: 6px 8px 0 8px;
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.note-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    cursor: pointer;
    font-size: 12px;
    max-width: 180px;
    min-width: 80px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.note-tab:hover { color: var(--text); }

.note-tab.active {
    color: var(--text);
    border-color: var(--primary);
    background: var(--bg-dark);
    font-weight: 600;
}

.note-tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-tab-close {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 13px;
}

.note-tab-close:hover {
    background: var(--warning);
    color: white;
}

/* Note options menu (⋯) */
.note-detail-header { position: relative; }

.note-menu {
    position: absolute;
    top: 36px;
    right: 36px;
    z-index: 300;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    min-width: 220px;
    overflow: hidden;
}

.note-menu button {
    background: none;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
}

.note-menu button:hover { background: rgba(102, 126, 234, 0.12); }
.note-menu button.danger { color: var(--warning); border-top: 1px solid var(--border); }
.note-menu button.danger:hover { background: rgba(250, 112, 154, 0.12); }
