/* CSS Variables */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 240px;
    --notes-panel-width: 320px;
    --transition: 0.15s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --surface-hover: #334155;
        --text: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;
        --border: #334155;
        --border-light: #1e293b;
    }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow: hidden;
}

/* ========== LOADING SCREEN ========== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-screen.hidden { display: none; }
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== ACCESSIBILITY ========== */
/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    z-index: 9999;
    font-weight: 500;
    text-decoration: none;
}
.skip-link:focus {
    top: 10px;
}

/* Focus styles for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Remove outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000;
        --text-muted: #555;
    }
}

/* ========== APP LAYOUT ========== */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.sidebar.open { transform: translateX(0); }

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.logo svg { width: 22px; height: 22px; }

.sidebar-close { display: block; }

.sidebar-search {
    padding: 12px 16px;
    position: relative;
    flex-shrink: 0;
}

.sidebar-search .search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.sidebar-search .search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}

.sidebar-search .search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.sidebar-nav {
    padding: 8px 12px;
    flex-shrink: 0;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.nav-item:hover { background: var(--surface-hover); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-section {
    flex-shrink: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    cursor: pointer;
}

.section-header:hover { color: var(--text-secondary); }

.collapse-icon {
    width: 14px;
    height: 14px;
    transition: transform var(--transition);
}

.section-header.collapsed .collapse-icon { transform: rotate(-90deg); }

.section-header .add-btn {
    margin-left: auto;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-header .add-btn:hover { color: var(--primary); background: var(--primary-light); }
.section-header .add-btn svg { width: 14px; height: 14px; }

.folders-list, .tags-list {
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
    max-height: none;
    overflow-y: visible;
}

.folder-item, .tag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
    width: 100%;
    flex-wrap: nowrap;
}

.folder-item:hover, .tag-item:hover { background: var(--surface-hover); }
.folder-item.active, .tag-item.active { background: var(--primary-light); color: var(--primary); }

.folder-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.folder-item.active svg { color: var(--primary); }
.folder-item .folder-name, .tag-item .tag-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.folder-item .note-count, .tag-item .note-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: auto;
}

.folder-action-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition), background var(--transition);
}

.folder-item:hover .folder-action-btn { opacity: 1; }
.folder-item:hover .note-count { display: none; }
.folder-action-btn:hover { background: var(--bg); color: var(--text); }
.folder-action-btn.delete-folder:hover { color: var(--danger); }
.folder-action-btn svg { width: 12px; height: 12px; }

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

/* ========== NOTES PANEL ========== */
.notes-panel {
    width: var(--notes-panel-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.notes-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.menu-btn { flex-shrink: 0; }

.view-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sort-select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
}

.sort-select:focus { border-color: var(--primary); }

/* Text Size Controls */
.text-size-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.text-size-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.text-size-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--text-muted);
}

.text-size-btn:active {
    background: var(--primary-light);
    color: var(--primary);
}

.text-size-btn svg {
    width: 16px;
    height: 16px;
}

.text-size-label {
    font-size: 0.75rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .text-size-btn {
        width: 36px;
        height: 36px;
    }

    .text-size-btn svg {
        width: 18px;
        height: 18px;
    }

    .text-size-label {
        font-size: 0.85rem;
    }
}

.add-note-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.add-note-btn:hover { background: var(--primary-hover); }
.add-note-btn svg { width: 18px; height: 18px; }

/* Bulk Actions Bar */
.bulk-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: var(--primary);
    color: white;
    gap: 4px;
}

.bulk-actions-bar.hidden { display: none; }

.bulk-actions-info {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.75rem;
    font-weight: 500;
}

.bulk-actions-buttons {
    display: flex;
    align-items: center;
    gap: 1px;
}

.bulk-action-btn {
    background: transparent;
    border: none;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.bulk-action-btn:hover { background: rgba(255,255,255,0.2); }
.bulk-action-btn.danger:hover { background: var(--danger); }
.bulk-action-btn svg { width: 15px; height: 15px; }
.bulk-action-btn.hidden { display: none; }

/* Select All Checkbox in Header */
.select-all-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-right: 4px;
    flex-shrink: 0;
}

.select-all-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.select-all-checkbox .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    transition: all var(--transition);
    position: relative;
}

.select-all-checkbox:hover .checkmark {
    border-color: var(--primary);
}

.select-all-checkbox input:checked ~ .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.select-all-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.select-all-checkbox input:checked ~ .checkmark::after {
    display: block;
}

.select-all-checkbox input:indeterminate ~ .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.select-all-checkbox input:indeterminate ~ .checkmark::after {
    display: block;
    left: 3px;
    top: 6px;
    width: 10px;
    height: 0;
    border-width: 0 0 2px 0;
    transform: none;
}

/* Bulk Tag Modal */
.tag-input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text);
    margin-bottom: 8px;
}

.tag-input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.bulk-tag-suggestions {
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 12px;
}

/* Note Item with Selection */
.note-item {
    position: relative;
}

.note-item-checkbox {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition), border-color var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-item:hover .note-item-checkbox,
.note-item.selected .note-item-checkbox,
.bulk-mode .note-item-checkbox {
    opacity: 1;
}

.note-item.selected .note-item-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.note-item.selected .note-item-checkbox svg {
    color: white;
}

.note-item-checkbox svg {
    width: 12px;
    height: 12px;
    color: transparent;
}

.bulk-mode .note-item {
    padding-left: 36px;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.note-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 4px;
    border-left: 3px solid transparent;
}

.note-item:hover { background: var(--surface-hover); }
.note-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.note-item.pinned { border-left-color: var(--primary); }

.note-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-item-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.note-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.note-item-star {
    color: #f59e0b;
}

.note-item-star svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.note-item-folder {
    display: flex;
    align-items: center;
    gap: 3px;
}

.note-item-folder svg { width: 10px; height: 10px; }

/* ========== PREVIEW PANEL ========== */
.preview-panel {
    flex: 1;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 40px;
}

.preview-empty svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }
.preview-empty p { font-size: 0.95rem; }

.preview-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.preview-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.preview-folder {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 12px;
}

.preview-actions {
    display: flex;
    gap: 4px;
}

.preview-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.preview-action-btn:hover { background: var(--surface-hover); color: var(--text); }
.preview-action-btn.delete:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.preview-action-btn.active { color: var(--primary); }
.preview-action-btn.starred { color: #f59e0b; }
.preview-action-btn.starred svg { fill: #f59e0b; }
.preview-action-btn svg { width: 18px; height: 18px; }

.preview-title {
    font-size: 1.75rem;
    font-weight: 700;
    padding: 24px 24px 12px;
    flex-shrink: 0;
}

.preview-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 24px 16px;
    flex-shrink: 0;
}

.preview-tag {
    font-size: 0.75rem;
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.preview-tag .remove-tag {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.preview-tag .remove-tag:hover {
    opacity: 1;
}

/* Tag Management Section */
.preview-tags-section {
    padding: 0 24px 12px;
    flex-shrink: 0;
}

.preview-tags-section .preview-tags {
    padding: 0;
    margin-bottom: 8px;
}

.preview-tag-input-wrapper {
    position: relative;
}

.preview-tag-input {
    width: 100%;
    max-width: 200px;
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.preview-tag-input:focus {
    border-color: var(--primary);
}

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

.preview-tag-input-wrapper .tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 100;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 2px;
}

.preview-tag-input-wrapper .tag-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
}

.preview-tag-input-wrapper .tag-suggestion:hover {
    background: var(--surface-hover);
}

.preview-body {
    flex: 1;
    overflow: auto;
    padding: 0 24px 40px;
}

/* ========== SIDEBAR OVERLAY ========== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

/* ========== ICON BUTTON ========== */
.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.active { color: var(--primary); }
.icon-btn svg { width: 20px; height: 20px; }
.delete-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
    box-shadow: var(--shadow-lg);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header .back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text);
    margin-right: 8px;
}

.modal-header .back-btn:hover {
    background: var(--surface-hover);
}

.modal-header .back-btn svg {
    width: 20px;
    height: 20px;
}

/* Hide on desktop, show on mobile */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
}

.modal-actions { display: flex; align-items: center; gap: 8px; }

.save-btn {
    height: 34px;
    padding: 0 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

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

/* ========== EDITOR ========== */
.editor-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-title-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    font-family: inherit;
    outline: none;
}

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

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    flex-shrink: 0;
}

.toolbar-group { display: flex; gap: 2px; }
.toolbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.toolbar-spacer { flex: 1; }

.toolbar-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.toolbar-btn:hover { background: var(--surface); color: var(--text); }
.toolbar-btn.active { background: var(--primary-light); color: var(--primary); }
.toolbar-btn svg { width: 16px; height: 16px; }
.toolbar-text { font-size: 0.7rem; font-weight: 600; }

.preview-toggle {
    width: auto;
    padding: 0 10px;
    gap: 4px;
    font-size: 0.75rem;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.note-content-input {
    flex: 1;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    line-height: 1.6;
    resize: none;
    outline: none;
}

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

.note-preview-pane {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.editor-footer {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.folder-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.folder-selector svg { width: 16px; height: 16px; color: var(--text-muted); }

.folder-select {
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.tags-input-container {
    flex: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    position: relative;
}

.selected-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    font-size: 0.75rem;
}

.selected-tag button {
    width: 14px;
    height: 14px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}

.selected-tag button:hover { opacity: 1; }
.selected-tag button svg { width: 10px; height: 10px; }

.tag-input {
    flex: 1;
    min-width: 80px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
}

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

.tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 120px;
    overflow-y: auto;
    z-index: 10;
}

.tag-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background var(--transition);
}

.tag-suggestion:hover { background: var(--surface-hover); }

.color-picker {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.color-btn {
    width: 26px;
    height: 26px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition);
    background: var(--surface);
}

.color-btn:hover { transform: scale(1.1); }
.color-btn.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.color-btn[data-color="#fef3c7"] { background: #fef3c7; }
.color-btn[data-color="#dcfce7"] { background: #dcfce7; }
.color-btn[data-color="#dbeafe"] { background: #dbeafe; }
.color-btn[data-color="#fce7f3"] { background: #fce7f3; }
.color-btn[data-color="#f3e8ff"] { background: #f3e8ff; }

/* ========== CONFIRM DIALOG ========== */
.confirm-dialog {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 360px;
    animation: modalIn 0.2s ease;
}

.confirm-dialog h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }

.folder-name-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    margin-bottom: 20px;
    outline: none;
}

.folder-name-input:focus { border-color: var(--primary); }

.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

.btn-secondary, .btn-primary, .btn-danger {
    height: 38px;
    padding: 0 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-secondary { background: var(--bg); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

/* ========== EMPTY STATE ========== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--surface);
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 400;
    animation: slideDown 0.3s ease;
}

.update-banner button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.update-banner button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.update-banner button.dismiss {
    background: transparent;
    padding: 4px 8px;
    font-size: 1.2rem;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ========== MARKDOWN ========== */
.markdown-body { font-size: 0.95rem; line-height: 1.7; color: var(--text); }
.markdown-body h1 { font-size: 1.6rem; font-weight: 700; margin: 1.25rem 0 0.75rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.3rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.markdown-body h3 { font-size: 1.1rem; font-weight: 600; margin: 0.75rem 0 0.5rem; }
.markdown-body p { margin: 0.6rem 0; }
.markdown-body a { color: var(--primary); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body strong { font-weight: 600; }
.markdown-body code { font-family: 'SF Mono', 'Consolas', monospace; font-size: 0.85em; background: var(--surface); padding: 0.2em 0.4em; border-radius: 4px; }
.markdown-body pre { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 16px; overflow-x: auto; margin: 0.75rem 0; }
.markdown-body pre code { background: none; padding: 0; font-size: 0.85rem; }
.markdown-body blockquote { margin: 0.75rem 0; padding: 0.5rem 1rem; border-left: 3px solid var(--primary); background: var(--primary-light); }
.markdown-body ul, .markdown-body ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.markdown-body li { margin: 0.25rem 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.9rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown-body th { background: var(--surface); font-weight: 600; }
.markdown-body input[type="checkbox"] { margin-right: 8px; accent-color: var(--primary); }

/* ========== ATTACHMENTS ========== */
.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    max-width: 200px;
}

.attachment-item.image {
    flex-direction: column;
    padding: 4px;
    max-width: 120px;
}

.attachment-item.image img {
    width: 100%;
    max-height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.attachment-item .attachment-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

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

.attachment-item .attachment-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.attachment-item .attachment-delete {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attachment-item .attachment-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.attachment-item .attachment-delete svg {
    width: 12px;
    height: 12px;
}

.attachment-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-weight: 500;
}

.drop-overlay-content svg {
    width: 48px;
    height: 48px;
}

.editor-area {
    position: relative;
}

.uploading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.uploading-indicator::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Preview attachments */
.preview-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 16px;
}

.preview-attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition);
}

.preview-attachment:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.preview-attachment svg {
    width: 14px;
    height: 14px;
}

/* ========== TEMPLATES ========== */
.template-picker {
    max-width: 500px;
    width: 90%;
}

.template-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    background: var(--surface);
}

.template-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.template-item .template-icon {
    width: 32px;
    height: 32px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}

.template-item .template-icon svg {
    width: 18px;
    height: 18px;
}

.template-item .template-info {
    flex: 1;
    min-width: 0;
}

.template-item .template-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.template-item .template-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== QUICK CAPTURE ========== */
.quick-capture-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 100;
}

.quick-capture-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.quick-capture-btn svg {
    width: 24px;
    height: 24px;
}

.quick-capture-dialog {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    animation: modalIn 0.2s ease;
    overflow: hidden;
}

.quick-capture-dialog textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
}

.quick-capture-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.quick-capture-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ========== NESTED FOLDERS ========== */
.folder-item.nested {
    padding-left: 28px;
}

.folder-item.nested-2 {
    padding-left: 44px;
}

/* ========== NOTE LINKS ========== */
.note-link {
    color: var(--primary);
    text-decoration: none;
    background: var(--primary-light);
    padding: 1px 4px;
    border-radius: 3px;
    cursor: pointer;
}

.note-link:hover {
    text-decoration: underline;
}

.note-link.not-found {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Link autocomplete */
.link-suggestions {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    z-index: 20;
    min-width: 200px;
}

.link-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background var(--transition);
}

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

@media (max-width: 640px) {
    .template-list {
        grid-template-columns: 1fr;
    }
    .quick-capture-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}

.hidden { display: none !important; }

/* ========== DESKTOP ========== */
@media (min-width: 1024px) {
    .sidebar {
        position: relative;
        transform: translateX(0);
    }
    .sidebar-close { display: none; }
    .sidebar-overlay { display: none !important; }
    .menu-btn { display: none; }
}

/* ========== BACK TO LIST BUTTON ========== */
.back-to-list {
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    margin-right: auto;
}
.back-to-list svg {
    width: 18px;
    height: 18px;
}
.back-to-list:hover {
    background: var(--surface-hover);
}

/* ========== TABLET ========== */
@media (max-width: 1023px) {
    .preview-panel {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        background: var(--surface);
    }
    .preview-panel.mobile-visible {
        display: flex;
        flex-direction: column;
    }
    body.preview-open .notes-panel { display: none; }
    .notes-panel { flex: 1; width: auto; }
    .back-to-list { display: flex; }
}

/* ========== MOBILE ========== */
@media (max-width: 640px) {
    .notes-panel-header { padding: 10px 12px; }
    .modal-content { max-height: 95vh; border-radius: var(--radius) var(--radius) 0 0; }
    .modal { align-items: flex-end; padding: 0; }

    /* Ensure inline editing works on mobile */
    .preview-content.editing .inline-edit-container {
        display: flex !important;
        flex: 1;
        padding: 0 16px 16px;
    }
    .inline-edit-title {
        padding: 12px 16px 8px;
        margin: 0 -16px;
        width: calc(100% + 32px);
    }
    .inline-toolbar {
        flex-wrap: wrap;
    }
    .inline-drawing-container {
        min-height: 250px;
    }
}

/* ========== INLINE EDITING ========== */
.inline-edit-container {
    display: none;
    flex-direction: column;
    flex: 1;
    padding: 0 24px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}
.preview-content.editing .preview-title,
.preview-content.editing .preview-tags-section,
.preview-content.editing .preview-attachments,
.preview-content.editing .preview-body {
    display: none;
}
.preview-content.editing .inline-edit-container {
    display: flex;
}
.preview-content.editing .preview-actions {
    display: none;
}
.preview-content.editing {
    overflow: hidden;
}
body:has(.preview-content.editing) .add-note-btn,
body:has(.preview-content.editing) .quick-capture-btn {
    display: none !important;
}
.inline-edit-title,
.inline-edit-content {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
    color: var(--text);
    font-family: inherit;
}
.inline-edit-title {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 16px 24px 8px;
    margin: 0 -24px;
    width: calc(100% + 48px);
}
.inline-edit-content {
    flex: 1;
    min-height: 200px;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    padding: 0;
}
.inline-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.inline-toolbar .toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.inline-toolbar .toolbar-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.inline-toolbar .toolbar-btn svg {
    width: 18px;
    height: 18px;
}
.inline-toolbar .toolbar-text {
    font-size: 0.75rem;
    font-weight: 600;
}
.inline-tags-section {
    position: relative;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
    overflow: visible;
    z-index: 50;
}
.inline-tags-section .selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.inline-tags-section .tag-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}
.inline-tags-section .tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
}
.inline-tags-section .tag-suggestion {
    padding: 8px 12px;
    cursor: pointer;
}
.inline-tags-section .tag-suggestion:hover {
    background: var(--surface-hover);
}
.inline-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
}

/* Mode Toggle */
.inline-mode-toggle {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.mode-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.mode-toggle-btn svg {
    width: 18px;
    height: 18px;
}

.mode-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

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

/* Inline Drawing */
.inline-drawing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.inline-drawing-tools {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-drawing-tools .drawing-tools-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.inline-drawing-tools .tools-row {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.inline-drawing-tools .drawing-tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.inline-drawing-tools .drawing-tool-btn:hover {
    background: var(--border);
    transform: scale(1.05);
}

.inline-drawing-tools .drawing-tool-btn.active {
    background: var(--primary);
    color: white;
}

.inline-drawing-tools .drawing-tool-btn svg {
    width: 20px;
    height: 20px;
}

.inline-drawing-tools .color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    max-width: 100%;
}

.inline-drawing-tools .drawing-color-btn {
    width: 28px;
    height: 28px;
    border: 3px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.inline-drawing-tools .drawing-color-btn:hover {
    transform: scale(1.15);
}

.inline-drawing-tools .drawing-color-btn.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--surface), 0 0 8px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

.inline-drawing-tools .size-options {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 0;
}

.inline-drawing-tools .drawing-size-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.inline-drawing-tools .drawing-size-btn:hover {
    border-color: var(--primary);
}

.inline-drawing-tools .drawing-size-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.inline-drawing-tools .drawing-size-btn span {
    background: var(--text);
    border-radius: 50%;
    display: block;
}

.inline-drawing-canvas {
    flex: 1;
    width: 100%;
    background: white;
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
}

@media (prefers-color-scheme: dark) {
    .inline-drawing-canvas {
        background: #1a1a2e;
    }
}

/* ========== VOICE RECORDING ========== */
.inline-voice-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 24px;
}

.voice-recorder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.voice-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.voice-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
}

.voice-waveform .waveform-bar {
    width: 6px;
    height: 20px;
    background: var(--border);
    border-radius: 3px;
    transition: height 0.1s ease;
}

.voice-waveform.recording .waveform-bar {
    background: var(--primary);
    animation: waveform 0.5s ease-in-out infinite alternate;
}

.voice-waveform.recording .waveform-bar:nth-child(1) { animation-delay: 0s; }
.voice-waveform.recording .waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-waveform.recording .waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-waveform.recording .waveform-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-waveform.recording .waveform-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveform {
    0% { height: 20px; }
    100% { height: 50px; }
}

.voice-timer {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.voice-timer.recording {
    color: #ef4444;
}

.voice-controls {
    display: flex;
    gap: 16px;
}

.voice-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.voice-btn svg {
    width: 28px;
    height: 28px;
}

.voice-btn.record {
    background: #ef4444;
    color: white;
}

.voice-btn.record:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.voice-btn.record.recording {
    animation: pulse-record 1.5s ease-in-out infinite;
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
}

.voice-btn.stop {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
}

.voice-btn.stop:hover {
    background: var(--border);
}

.voice-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.voice-playback {
    width: 100%;
    max-width: 400px;
}

.voice-audio {
    display: none;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.voice-btn.play,
.voice-btn.pause {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    flex-shrink: 0;
}

.voice-btn.play:hover,
.voice-btn.pause:hover {
    opacity: 0.9;
}

.voice-btn.play svg,
.voice-btn.pause svg {
    width: 20px;
    height: 20px;
}

.playback-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.progress-bar .progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}

.voice-duration {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
}

.voice-btn.delete {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.voice-btn.delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.voice-btn.delete svg {
    width: 18px;
    height: 18px;
}

/* Voice note in preview */
.voice-note-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 16px 0;
}

.voice-note-player .play-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-note-player .play-btn:hover {
    opacity: 0.9;
}

.voice-note-player .play-btn svg {
    width: 20px;
    height: 20px;
}

.voice-note-player .progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-note-player .progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.voice-note-player .progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
}

.voice-note-player .duration {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.voice-note-text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.voice-note-loading,
.voice-note-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.voice-note-error {
    color: #ef4444;
}

/* ========== FULLSCREEN MODE ========== */
/* Hide other panels when fullscreen is active */
body.fullscreen-active .sidebar,
body.fullscreen-active .notes-panel,
body.fullscreen-active .sidebar-overlay {
    display: none !important;
}

body.fullscreen-active .preview-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.preview-panel.is-fullscreen {
    background: var(--surface);
}

.preview-panel.is-fullscreen .preview-content {
    max-width: 100%;
    height: 100%;
}

.preview-panel.is-fullscreen .preview-header {
    padding: 12px 24px;
}

.preview-panel.is-fullscreen .inline-edit-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px 24px;
}

.preview-panel.is-fullscreen .inline-drawing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preview-panel.is-fullscreen .inline-drawing-canvas {
    flex: 1;
    width: 100% !important;
    height: auto !important;
    min-height: 500px;
}

.preview-panel.is-fullscreen .inline-edit-content {
    flex: 1;
    font-size: 1.1rem;
    line-height: 1.8;
    min-height: 400px;
}

.preview-panel.is-fullscreen .preview-body {
    max-width: 900px;
    margin: 0 auto;
    font-size: 1.1rem;
    line-height: 1.8;
    padding: 0 32px 40px;
}

.preview-panel.is-fullscreen .preview-title {
    font-size: 2rem;
    padding: 24px 32px 12px;
}

/* Fullscreen toggle button */
#fullscreenToggle {
    position: relative;
}

#fullscreenToggle .fullscreen-enter,
#fullscreenToggle .fullscreen-exit {
    width: 18px;
    height: 18px;
}

/* Mobile fullscreen adjustments */
@media (max-width: 768px) {
    .preview-panel.is-fullscreen .inline-edit-container {
        padding: 0 16px 16px;
    }

    .preview-panel.is-fullscreen .preview-body {
        padding: 0 16px 24px;
    }

    .preview-panel.is-fullscreen .preview-title {
        font-size: 1.5rem;
        padding: 16px 16px 8px;
    }

    .preview-panel.is-fullscreen .inline-drawing-canvas {
        min-height: calc(100vh - 200px);
    }
}

/* ========== AUTH SCREEN ========== */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.auth-container {
    width: 100%;
    max-width: 380px;
    padding: 24px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo svg {
    width: 48px;
    height: 48px;
    stroke: var(--primary);
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 12px;
}

.auth-form {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.auth-form h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

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

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.auth-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}

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

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ========== SIDEBAR FOOTER ========== */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.user-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-info svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: 4px;
}

/* ========== THEME TOGGLE ========== */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-light: #1e293b;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
}

.theme-icon-light,
.theme-icon-dark {
    width: 18px;
    height: 18px;
}

[data-theme="dark"] .theme-icon-light { display: none !important; }
[data-theme="dark"] .theme-icon-dark { display: block !important; }
[data-theme="light"] .theme-icon-light { display: block !important; }
[data-theme="light"] .theme-icon-dark { display: none !important; }

/* ========== SHARE MODAL ========== */
.share-dialog {
    min-width: 320px;
}

.share-content {
    margin: 16px 0;
}

.share-toggle {
    margin-bottom: 16px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-text {
    font-size: 0.95rem;
    color: var(--text);
}

.share-url-section {
    display: flex;
    gap: 8px;
}

.share-url-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}

/* ========== EXPORT MODAL ========== */
.export-dialog {
    min-width: 280px;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.export-option:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.export-option svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-secondary);
}

.export-option span {
    font-size: 0.95rem;
    color: var(--text);
}

/* ========== HISTORY MODAL ========== */
.history-dialog {
    min-width: 400px;
    max-width: 500px;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 16px 0;
}

.history-list .loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background var(--transition);
}

.history-item:hover {
    background: var(--surface-hover);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item-version {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-weight: 500;
}

.no-history {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 20px;
}

/* ========== VERSION PREVIEW MODAL ========== */
.version-preview-modal {
    max-width: 700px;
    width: 90%;
}

.version-preview-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
    .share-dialog,
    .export-dialog,
    .history-dialog {
        min-width: auto;
        width: 100%;
    }
}

/* ========== NAV DIVIDER ========== */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

/* ========== IMPORT MODAL ========== */
.import-dialog {
    min-width: 320px;
    max-width: 400px;
}

.import-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.import-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.import-option:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.import-option svg {
    width: 28px;
    height: 28px;
    stroke: var(--primary);
}

.import-option span {
    font-size: 0.85rem;
    color: var(--text);
}

.import-progress {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.import-progress::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

/* ========== REMINDER MODAL ========== */
.reminder-dialog {
    min-width: 340px;
}

.reminder-content {
    margin: 16px 0;
}

.reminder-note-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reminder-input-group {
    margin-bottom: 16px;
}

.reminder-input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.reminder-datetime {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.reminder-datetime:focus {
    outline: none;
    border-color: var(--primary);
}

.reminder-quick-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reminder-quick-btn {
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.reminder-quick-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== REMINDERS LIST MODAL ========== */
.reminders-list-dialog {
    min-width: 400px;
    max-width: 500px;
}

.reminders-list {
    max-height: 350px;
    overflow-y: auto;
    margin: 16px 0;
}

.reminders-list .loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.reminder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background var(--transition);
}

.reminder-item:hover {
    background: var(--surface-hover);
}

.reminder-item.overdue {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.reminder-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.reminder-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--primary);
}

.reminder-item.overdue .reminder-icon {
    background: rgba(239, 68, 68, 0.1);
}

.reminder-item.overdue .reminder-icon svg {
    stroke: var(--danger);
}

.reminder-info {
    flex: 1;
    min-width: 0;
}

.reminder-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reminder-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.reminder-item.overdue .reminder-time {
    color: var(--danger);
}

.reminder-actions {
    display: flex;
    gap: 4px;
}

.reminder-action-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.reminder-action-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.reminder-action-btn.complete:hover {
    color: #22c55e;
}

.reminder-action-btn.delete:hover {
    color: var(--danger);
}

.reminder-action-btn svg {
    width: 16px;
    height: 16px;
}

.no-reminders {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.no-reminders svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========== NOTIFICATION BADGE ========== */
.nav-item .nav-count.has-items {
    background: var(--primary);
    color: white;
}

@media (max-width: 640px) {
    .import-dialog,
    .reminder-dialog,
    .reminders-list-dialog {
        min-width: auto;
        width: 100%;
    }

    .import-options {
        grid-template-columns: 1fr;
    }
}

/* ========== DRAWING CANVAS ========== */
.drawing-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
}

.drawing-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-wrap: wrap;
}

.drawing-tools,
.drawing-colors,
.drawing-sizes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.drawing-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.drawing-spacer {
    flex: 1;
}

.drawing-tool-btn,
.drawing-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.drawing-tool-btn:hover,
.drawing-action-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.drawing-tool-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.drawing-tool-btn svg,
.drawing-action-btn svg {
    width: 20px;
    height: 20px;
}

.drawing-color-btn {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition);
}

.drawing-color-btn:hover {
    transform: scale(1.1);
}

.drawing-color-btn.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--surface);
}

.drawing-size-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.drawing-size-btn:hover {
    background: var(--surface-hover);
}

.drawing-size-btn.active {
    background: var(--primary-light);
}

.size-dot {
    background: var(--text);
    border-radius: 50%;
}

.drawing-size-btn.active .size-dot {
    background: var(--primary);
}

.drawing-canvas {
    flex: 1;
    cursor: crosshair;
    touch-action: none;
    background: white;
}

/* Toggle button active state for drawing mode */
#toggleDrawingMode.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Drawing note card thumbnail */
.note-card .drawing-thumbnail,
.note-item .drawing-thumbnail {
    max-width: 100%;
    max-height: 120px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    object-fit: contain;
    background: white;
}

/* Preview drawing - honor original resolution, don't resize */
.preview-body:has(.preview-drawing) {
    display: block;
}

.preview-drawing {
    display: inline-block;
    border-radius: var(--radius);
    background: white;
    box-shadow: var(--shadow-sm);
    /* Don't scale the image - show at original resolution */
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: none;
}

/* Drawing mode indicator */
.drawing-mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 8px;
}

.drawing-mode-indicator svg {
    width: 12px;
    height: 12px;
}

.voice-mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 8px;
}

.voice-mode-indicator svg {
    width: 12px;
    height: 12px;
}

.note-item-preview.voice-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.note-item-preview.voice-preview svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Hide text formatting tools in drawing mode */
.editor-toolbar.drawing-mode .toolbar-group:not(:first-child),
.editor-toolbar.drawing-mode .toolbar-divider:not(:first-of-type),
.editor-toolbar.drawing-mode .toolbar-spacer,
.editor-toolbar.drawing-mode .preview-toggle {
    display: none;
}

/* ========== OFFLINE / PWA ========== */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--text);
    color: var(--bg);
    border-radius: 30px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideUp 0.3s ease;
}

.offline-indicator svg {
    width: 18px;
    height: 18px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Auth screen free tier info */
.auth-free-tier {
    margin-top: 24px;
    padding: 16px;
    background: var(--surface-hover);
    border-radius: var(--radius);
    text-align: left;
}

.auth-free-tier p {
    margin: 0 0 8px;
    font-size: 0.9rem;
}

.auth-free-tier ul {
    margin: 0;
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-free-tier li {
    margin: 4px 0;
}

.auth-free-tier .plan-note {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.auth-legal {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.auth-legal a {
    color: var(--text-secondary);
    text-decoration: none;
}

.auth-legal a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.auth-legal span {
    margin: 0 8px;
}

/* Usage indicator in sidebar */
.usage-indicator {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
}

.usage-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px 0 4px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.usage-bar-fill.warning {
    background: #f59e0b;
}

.usage-bar-fill.danger {
    background: var(--danger);
}

.usage-text {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
}

.usage-text.warning {
    color: #f59e0b;
}

.usage-text.danger {
    color: var(--danger);
}

body.offline-mode .offline-indicator {
    display: flex;
}

/* Sync settings dialog */
.sync-settings-dialog {
    min-width: 400px;
    max-width: 500px;
}

.sync-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.folder-sync-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.folder-sync-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.folder-sync-item:last-child {
    border-bottom: none;
}

.folder-sync-item label:not(.sync-toggle) {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    cursor: pointer;
}

.folder-sync-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.folder-sync-item .folder-name {
    font-weight: 500;
}

.folder-sync-item .folder-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Sync toggle switch */
.sync-toggle {
    position: relative;
    flex: 0 0 44px;
    width: 44px;
    height: 24px;
}

.sync-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.sync-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: all var(--transition);
}

.sync-toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition);
}

.sync-toggle input:checked + .sync-toggle-slider {
    background: var(--primary);
}

.sync-toggle input:checked + .sync-toggle-slider::before {
    transform: translateX(20px);
}

.sync-storage-info {
    padding: 12px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Synced folder indicator in sidebar */
.folder-item .sync-badge {
    width: 12px;
    height: 12px;
    color: var(--primary);
    margin-left: auto;
    opacity: 0.7;
}

/* Cached data indicator */
.note-item.from-cache::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.5;
}

/* PWA install prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
}

.pwa-install-prompt button {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
}

.pwa-install-btn {
    background: var(--primary);
    color: white;
}

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

@media (max-width: 640px) {
    .sync-settings-dialog {
        min-width: auto;
        width: 100%;
    }

    .offline-indicator {
        bottom: 70px;
    }
}

/* ========== MOBILE ACCESSIBILITY ========== */
@media (max-width: 768px) {
    /* Increase base font size on mobile */
    html {
        font-size: 18px;
    }

    /* Ensure minimum touch target of 44px */
    button, .btn, .nav-item, .folder-item, .tag-item, .note-item,
    .toolbar-btn, .color-btn, .action-btn, input, select, textarea {
        min-height: 44px;
    }

    /* Increase font sizes throughout */
    .nav-item {
        font-size: 1rem;
        padding: 12px 16px;
    }

    .nav-count {
        font-size: 0.875rem;
        padding: 4px 10px;
    }

    .section-header {
        font-size: 0.8rem;
        padding: 14px 16px 10px;
    }

    .folder-item, .tag-item {
        font-size: 1rem;
        padding: 12px 16px;
        min-height: 48px;
    }

    .folder-item .note-count, .tag-item .note-count {
        font-size: 0.875rem;
    }

    .note-item {
        padding: 14px 16px;
    }

    .note-item-title {
        font-size: 1.05rem;
    }

    .note-item-preview {
        font-size: 0.95rem;
    }

    .note-item-meta {
        font-size: 0.85rem;
    }

    .view-title {
        font-size: 1.15rem;
    }

    .sort-select {
        font-size: 0.9rem;
        min-height: 44px;
        padding: 8px 12px;
    }

    /* Editor improvements */
    .editor-title {
        font-size: 1.5rem;
        min-height: 48px;
    }

    .editor-textarea {
        font-size: 1.1rem;
        line-height: 1.7;
    }

    .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .toolbar-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Modal improvements */
    .modal-header h2 {
        font-size: 1.25rem;
    }

    .confirm-dialog h3 {
        font-size: 1.2rem;
    }

    .confirm-dialog p {
        font-size: 1rem;
    }

    .folder-name-input {
        font-size: 1.1rem;
        padding: 14px 16px;
        min-height: 48px;
    }

    .btn {
        font-size: 1rem;
        min-height: 48px;
        padding: 12px 20px;
    }

    /* Auth screen */
    .auth-form h2 {
        font-size: 1.4rem;
    }

    .auth-input {
        font-size: 1.1rem;
        padding: 14px 16px;
        min-height: 48px;
    }

    .auth-btn {
        font-size: 1.1rem;
        min-height: 52px;
    }

    .auth-switch {
        font-size: 1rem;
    }

    .auth-free-tier p {
        font-size: 1rem;
    }

    .auth-free-tier ul {
        font-size: 0.95rem;
    }

    /* Preview panel text */
    .preview-title {
        font-size: 1.5rem;
    }

    .preview-meta {
        font-size: 0.9rem;
    }

    .preview-tag {
        font-size: 0.875rem;
        padding: 6px 12px;
    }

    /* Markdown content */
    .markdown-body {
        font-size: 1.1rem;
    }

    .markdown-body h1 {
        font-size: 1.75rem;
    }

    .markdown-body h2 {
        font-size: 1.4rem;
    }

    .markdown-body h3 {
        font-size: 1.2rem;
    }

    /* Toast */
    .toast {
        font-size: 1rem;
        padding: 14px 28px;
    }

    /* Dialogs */
    .import-option, .export-option, .template-item {
        min-height: 56px;
        padding: 14px 16px;
    }

    .import-option span, .export-option span {
        font-size: 1rem;
    }

    .template-item .template-name {
        font-size: 1rem;
    }

    .template-item .template-desc {
        font-size: 0.9rem;
    }

    /* Reminders */
    .reminder-input-group label {
        font-size: 1rem;
    }

    .reminder-input-group input {
        font-size: 1.1rem;
        min-height: 48px;
    }

    .reminder-quick-btn {
        font-size: 0.9rem;
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Tags */
    .tag-input {
        font-size: 1rem;
        min-height: 44px;
    }

    .selected-tag {
        font-size: 0.9rem;
        padding: 8px 14px;
    }

    .tag-suggestion {
        font-size: 1rem;
        padding: 12px 16px;
        min-height: 44px;
    }

    /* FAB */
    .fab {
        width: 60px;
        height: 60px;
    }

    .fab svg {
        width: 28px;
        height: 28px;
    }

    /* Usage indicator */
    .usage-indicator {
        font-size: 0.9rem;
        padding: 14px 16px;
    }

    /* Quick capture */
    .quick-capture-input {
        font-size: 1.1rem;
    }

    .quick-capture-hint {
        font-size: 0.9rem;
    }

    /* Search */
    .search-input {
        font-size: 1rem;
        min-height: 44px;
    }

    /* History/Versions */
    .history-item {
        padding: 14px 16px;
        min-height: 56px;
    }

    .history-item-meta {
        font-size: 0.9rem;
    }

    .history-item-version {
        font-size: 0.875rem;
    }

    /* Attachments */
    .attachment-item {
        padding: 12px;
        min-height: 48px;
    }

    .attachment-item .attachment-size {
        font-size: 0.85rem;
    }

    /* Sidebar user section */
    .user-name {
        font-size: 1rem;
    }

    /* Folder select in editor */
    .folder-select {
        font-size: 1rem;
        min-height: 44px;
    }

    /* Sync settings */
    .folder-sync-item {
        min-height: 56px;
        padding: 14px 16px;
    }

    .folder-sync-item .folder-count {
        font-size: 0.875rem;
    }

    .sync-storage-info {
        font-size: 0.9rem;
    }

    /* Legal links */
    .auth-legal {
        font-size: 0.9rem;
    }

    /* PWA install */
    .pwa-install-prompt button {
        font-size: 1rem;
        min-height: 44px;
        padding: 10px 16px;
    }
}

/* Extra small devices - even larger text */
@media (max-width: 375px) {
    html {
        font-size: 17px;
    }
}

/* ========== SCREEN READER ONLY ========== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========== ACCOUNT SETTINGS MODAL ========== */
.account-modal {
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.account-sections {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.account-section {
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.account-section h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.account-field {
    margin-bottom: 12px;
}

.account-field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.account-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}

.account-field input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.account-field input:focus {
    outline: none;
    border-color: var(--primary);
}

.account-message {
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.account-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.account-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.usage-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.usage-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.usage-stat .usage-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.usage-stat .usage-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}

.usage-stat .usage-bar {
    height: 8px;
    background: var(--surface-hover);
    border-radius: 4px;
    overflow: hidden;
}

.usage-stat .usage-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.usage-stat .usage-fill.warning {
    background: #f59e0b;
}

.usage-stat .usage-fill.danger {
    background: var(--danger);
}

.danger-zone {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition);
}

.btn-danger:hover {
    opacity: 0.9;
}

#deleteAccountModal .account-field {
    margin: 16px 0;
}

#deleteAccountModal .account-message {
    margin: 12px 0;
}

/* Account Sync Section */
.account-section .section-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.account-section .folder-sync-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.account-section .folder-sync-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.account-section .folder-sync-item:last-child {
    border-bottom: none;
}

.account-section .folder-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.account-section .folder-info svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.account-section .sync-toggle {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
}

.sync-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sync-storage-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-sm {
    height: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
}

.sync-unavailable {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Auto-save indicator */
.auto-save-indicator {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.auto-save-indicator.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.indicator-dot.pending {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.indicator-dot.saving {
    background: #3b82f6;
    animation: pulse 0.5s infinite;
}

.indicator-dot.saved {
    background: #22c55e;
}

.indicator-dot.saved-offline {
    background: #f59e0b;
}

.indicator-dot.error {
    background: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Offline mode indicator */
body.offline-mode::before {
    content: 'Offline - changes will sync when online';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 4px 12px;
    background: #f59e0b;
    color: #000;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 10000;
}

body.offline-mode .auto-save-indicator {
    top: 32px;
}

/* Inline edit area container for drag-drop */
.inline-edit-area {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.inline-edit-area .drop-overlay {
    border-radius: var(--radius);
}

/* Toolbar separator */
.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

/* Preview attachments */
.preview-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px;
    margin-bottom: 12px;
}

.preview-attachment-item {
    flex-shrink: 0;
}

.preview-attachment-image {
    max-width: 120px;
    max-height: 80px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.preview-attachment-image:hover {
    transform: scale(1.05);
}

.preview-attachment-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}

.preview-attachment-link:hover {
    background: var(--border);
}
