/**
 * Enhanced AI Canvas Styles for LifeNotes
 * Advanced styling with animations, accessibility, and mobile responsiveness
 */

/* CSS Custom Properties for theming */
:root {
    /* Color Palette */
    --primary-color: #667eea;
    --primary-light: #8b9eff;
    --primary-dark: #4c63d2;
    /* Hyperlinks in notes / link cards — lighter than --primary-color */
    --ln-note-link: #9ca8f7;
    --ln-note-link-hover: #7d8cf0;
    --secondary-color: #764ba2;
    --accent-color: #10b981;
    --success-color: #059669;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Background Colors */
    --bg-primary: var(--white);
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    
    /* Text Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-500);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Z-index layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* Floating bar chrome — canvas toolbar + Today panel (shared tokens) */
:root {
    --ln-float-bg: rgba(255, 255, 255, 0.92);
    --ln-float-border: rgba(15, 23, 42, 0.08);
    --ln-float-shadow: none;
    --ln-float-radius: 10px;
    --ln-float-backdrop: blur(10px);
    --ln-float-muted: rgba(15, 23, 42, 0.55);
    --ln-float-muted-strong: rgba(15, 23, 42, 0.82);
    --ln-float-hover: rgba(15, 23, 42, 0.06);
    --ln-float-pad: 6px;
    --ln-float-gap: 6px;
    --ln-float-icon: 16px;
    --ln-float-control-radius: 6px;
    --ln-float-control-size: 36px;
    --ln-float-inset-right: max(20px, env(safe-area-inset-right, 20px));
}

@media (max-width: 768px) {
    :root {
        --ln-float-inset-right: max(10px, env(safe-area-inset-right, 10px));
    }
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-primary: var(--gray-900);
    --bg-secondary: var(--gray-800);
    --bg-tertiary: var(--gray-700);
    --text-primary: var(--gray-100);
    --text-secondary: var(--gray-300);
    --text-tertiary: var(--gray-400);
    --ln-note-link: #a5b4fc;
    --ln-note-link-hover: #c7d2fe;
}

/* Floating bars stay light on all themes (canvas chrome, not app shell) */
.canvas-toolbar,
.ln-today-strip {
    --ln-float-bg: rgba(255, 255, 255, 0.92);
    --ln-float-border: rgba(15, 23, 42, 0.08);
    --ln-float-shadow: none;
    --ln-float-muted: rgba(15, 23, 42, 0.55);
    --ln-float-muted-strong: rgba(15, 23, 42, 0.82);
    --ln-float-hover: rgba(15, 23, 42, 0.06);
    background: var(--ln-float-bg);
    border-color: var(--ln-float-border);
    box-shadow: var(--ln-float-shadow);
    color: var(--ln-float-muted-strong);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessibility improvements */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--white);
    padding: var(--spacing-sm) var(--spacing-md);
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    transition: var(--transition-fast);
}

.skip-link:focus {
    top: 6px;
}

/* Canvas container */
#noteCanvas {
    position: relative;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    padding: var(--spacing-lg);
    cursor: text;
    background: #ffffff;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.canvas-marquee-select {
    position: absolute;
    border: 1px solid rgba(102, 126, 234, 0.7);
    background: rgba(102, 126, 234, 0.14);
    border-radius: 4px;
    pointer-events: none;
    z-index: 1100;
}

/* Canvas brand logo - subtle watermark */
.canvas-brand {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    z-index: 1;
    user-select: none;
    pointer-events: none;
}

.brand-logo,
.brand-tagline {
    pointer-events: none;
}

.canvas-page-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    max-width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}

.canvas-page-header[hidden] {
    display: none !important;
}

.canvas-page-name {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    line-height: 1.3;
    letter-spacing: 0.01em;
    background: none;
    border: none;
    padding: 2px 0;
    margin: 0;
    cursor: default;
    text-align: left;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.canvas-page-name-input {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
    line-height: 1.3;
    letter-spacing: 0.01em;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 2px 8px;
    margin: 0;
    min-width: 120px;
    max-width: min(340px, calc(100vw - 80px));
    box-sizing: border-box;
    pointer-events: auto;
}

.canvas-page-name-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.canvas-page-name-input[hidden] {
    display: none !important;
}

.canvas-page-settings-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    pointer-events: auto;
}

.canvas-page-settings-btn:hover:not(:disabled),
.canvas-page-settings-btn:focus-visible {
    color: #64748b;
    background: rgba(148, 163, 184, 0.15);
    outline: none;
}

.canvas-page-settings-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rename-page-overlay {
    position: fixed;
    inset: 0;
    z-index: 10040;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    padding: 20px;
}

.rename-page-overlay[hidden] {
    display: none !important;
}

.rename-page-dialog {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.rename-page-dialog h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #111827;
}

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

.rename-page-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

.rename-page-actions .btn-primary {
    background: #667eea;
    color: #fff;
}

.rename-page-actions .btn-primary:hover {
    background: #5a67d8;
}

.rename-page-actions .btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.rename-page-actions .btn-secondary:hover {
    background: #e5e7eb;
}

.canvas-settings-help {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.45;
    margin: 0 0 16px;
}

.canvas-settings-field {
    margin-bottom: 14px;
}

.canvas-settings-field label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
}

.canvas-settings-field input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.canvas-settings-field--number label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
    cursor: default;
}

.canvas-settings-field--number input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
}

.brand-logo {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.875rem;
    font-weight: 300;
    color: #e8e8e8;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.brand-tagline {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.6875rem;
    font-weight: 300;
    color: #e0e0e0;
    line-height: 1.3;
    margin-top: 2px;
    letter-spacing: 0.01em;
}

/* Content blocks */
.content-block {
    position: absolute;
    max-width: 600px;
    min-width: 80px;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.4s ease-out;
    z-index: 1;
    cursor: grab;
    border: 1px solid #e5e7eb; /* Very light gray border */
    will-change: transform; /* Optimize for transforms */
    touch-action: none; /* Prevent default touch behaviors */
}

.content-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--gray-200);
}

.content-block:active {
    cursor: grabbing;
}

/* Optimized styles for dragging - no transitions, hardware acceleration */
.content-block.dragging {
    transition: none !important;
    cursor: grabbing !important;
    user-select: none !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
    transform: none; /* Remove hover transform during drag */
    will-change: left, top; /* Optimize position changes */
}

/* Manual resize up to hard max (600 = soft cap for auto layout) */
.content-block.card-layout-manual {
    max-width: 1000px;
}

.content-block.card-resizing {
    user-select: none;
    transition: none !important;
    transform: none !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
    will-change: width, height, left;
}

.card-resize-handle {
    position: absolute;
    z-index: 25;
    pointer-events: auto;
    touch-action: none;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

/* Wider hit targets so left/right edges are easy to grab */
.card-resize-w {
    top: 0;
    left: 0;
    width: 14px;
    height: calc(100% - 14px);
    cursor: ew-resize;
}

.card-resize-e {
    top: 0;
    right: 0;
    width: 14px;
    height: calc(100% - 14px);
    cursor: ew-resize;
}

.card-resize-s {
    left: 0;
    bottom: 0;
    width: 100%;
    height: 14px;
    cursor: ns-resize;
}

.card-resize-se {
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

/* Narrow cards: single-line preview. Do NOT use display:-webkit-box on contenteditable — it stacks glyphs and pins them to the edge in WebKit/Blink. */
.content-block.card--compact[contenteditable="true"]:not(.link-note) {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}

.content-block.card--compact[contenteditable="true"]:not(.link-note):focus {
    white-space: normal;
    overflow-y: auto;
    overflow-x: hidden;
}


.content-block.focused {
    border-color: rgba(165, 180, 252, 0.55);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.12);
}

.content-block.user .block-note-body:focus {
    outline: none;
}

.content-block.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Block types */
.content-block.user {
    background: rgba(255, 255, 255, 0.95);
    border-left: 4px solid var(--primary-color);
}

.content-block.system {
    background: rgba(255, 255, 255, 0.85);
    border-left: 4px solid var(--accent-color);
    font-style: italic;
}

.content-block.note {
    background: rgba(255, 255, 255, 0.9);
    border-left: 4px solid var(--warning-color);
}

/* URL object_type temporary object cards (not persisted until user adds note text). */
.content-block.ln-temp-object-block {
    border-left: 4px solid #0ea5e9;
    background: #ffffff;
}

.content-block.ln-temp-object-block .ln-temp-object-badge {
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 11px;
    line-height: 1.3;
    font-weight: 600;
}

.content-block.ln-temp-object-block .ln-temp-object-preview {
    margin: 0 0 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    line-height: 1.45;
    max-height: 200px;
    overflow: auto;
}

.content-block.ln-temp-object-block .ln-temp-object-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.content-block.ln-temp-object-block .ln-temp-object-list li {
    display: grid;
    grid-template-columns: minmax(100px, 35%) 1fr;
    gap: 8px;
    align-items: start;
    padding: 3px 0;
    border-bottom: 1px solid #eef2f7;
}

.content-block.ln-temp-object-block .ln-temp-object-list li:last-child {
    border-bottom: 0;
}

.content-block.ln-temp-object-block .ln-temp-object-key {
    color: #0f172a;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.content-block.ln-temp-object-block .ln-temp-object-value {
    color: #334155;
    overflow-wrap: anywhere;
}

.content-block.ln-temp-object-block .ln-temp-object-more {
    display: block;
    color: #64748b;
    font-style: italic;
    padding-top: 6px;
}

.content-block.search-result {
    background: rgba(255, 255, 255, 0.88);
    border-left: 4px solid var(--info-color);
}

.content-block.help {
    background: rgba(255, 255, 255, 0.92);
    border-left: 4px solid var(--info-color);
}

.content-block.error {
    background: rgba(255, 255, 255, 0.95);
    border-left: 4px solid var(--error-color);
}

.content-block.pinned {
    border-top: 3px solid var(--warning-color);
}

/* Editable blocks */
.content-block[contenteditable="true"] {
    outline: none;
    border: 1px solid #e5e7eb; /* Very light gray border */
    background: rgba(255, 255, 255, 0.98);
    cursor: text;
    padding: var(--spacing-lg) var(--spacing-xl);
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    direction: ltr;
    text-align: left;
}

.content-block[contenteditable="true"]:focus {
    border: 1px solid #d1d5db; /* Slightly darker gray on focus */
    box-shadow: 0 0 0 2px rgba(229, 231, 235, 0.3);
}

/* When block has no header, adjust padding to start text exactly where clicked */
.content-block[contenteditable="true"]:not(:has(.block-header)) {
    padding: var(--spacing-lg) var(--spacing-xl);
    min-height: 1.5em;
    line-height: 1.5;
}

/* Ensure text starts at the beginning of the block */
.content-block[contenteditable="true"]:not(:has(.block-header))::before {
    content: '';
    display: inline;
}

/* Block header */
.block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    gap: var(--spacing-sm);
}

.block-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.block-timestamp {
    opacity: 0.7;
    font-size: 0.7rem;
}

.block-actions {
    display: flex;
    gap: var(--spacing-xs);
    opacity: 0;
    transition: var(--transition-fast);
}

.content-block:hover .block-actions {
    opacity: 1;
}

/* On touch devices, actions are shown on tap-to-select (is-mobile-focused class toggled by JS) */
body[data-touch="true"] .content-block .block-actions {
    opacity: 0;
    transition: var(--transition-fast);
}
body[data-touch="true"] .content-block.is-mobile-focused .block-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: var(--transition-fast);
    opacity: 0.7;
}

.action-btn:hover {
    opacity: 1;
    background: var(--gray-100);
}

/* Block content */
.block-content {
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.block-content p {
    margin-bottom: var(--spacing-sm);
}

.block-content p:last-child {
    margin-bottom: 0;
}

/* Note title */
.note-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    line-height: 1.4;
}

/* Tags */
.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.note-tag {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
    padding: 2px var(--spacing-sm);
    border-radius: var(--radius-lg);
    font-size: 0.7rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.note-tag:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
}

/* Search results */
.search-results {
    margin-top: var(--spacing-md);
}

.search-result-item {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    background: rgba(139, 92, 246, 0.05);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--info-color);
    transition: var(--transition-fast);
    cursor: pointer;
}

.search-result-item:hover {
    background: rgba(139, 92, 246, 0.1);
    transform: translateX(2px);
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.search-result-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.search-result-excerpt {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Recent notes */
.recent-notes {
    margin-top: var(--spacing-md);
}

.recent-note-item {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: rgba(245, 158, 11, 0.05);
    border-radius: var(--radius-md);
    border-left: 2px solid var(--warning-color);
    opacity: 0.8;
    transition: var(--transition-fast);
    cursor: pointer;
}

.recent-note-item:hover {
    opacity: 1;
    background: rgba(245, 158, 11, 0.1);
}

.recent-note-item:last-child {
    margin-bottom: 0;
}

/* Help suggestions */
.help-suggestions {
    margin-top: var(--spacing-md);
}

.help-suggestion {
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-xs);
    background: rgba(6, 182, 212, 0.05);
    border-radius: var(--radius-md);
    border-left: 2px solid var(--info-color);
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.help-suggestion:hover {
    background: rgba(6, 182, 212, 0.1);
    transform: translateX(2px);
}

.help-suggestion:last-child {
    margin-bottom: 0;
}

/* Keyboard shortcuts section */
.keyboard-shortcuts {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.keyboard-shortcuts h4 {
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
}

.keyboard-shortcuts ul {
    list-style: none;
    padding: 0;
}

.keyboard-shortcuts li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

kbd {
    background: var(--gray-200);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 2px var(--spacing-xs);
    font-size: 0.7rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    color: var(--text-primary);
}

/* Loading indicator */
.loading-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: var(--spacing-sm);
}

/* AI label */
.ai-label {
    display: inline-flex;
    align-items: center;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
    padding: 2px var(--spacing-sm);
    border-radius: var(--radius-lg);
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: var(--spacing-sm);
}

.ai-label::before {
    content: "🤖";
    margin-right: var(--spacing-xs);
}

/* Clickable elements */
.clickable {
    cursor: pointer;
    transition: var(--transition-fast);
}

.clickable:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: translateY(-1px);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -8px, 0);
    }
    70% {
        transform: translate3d(0, -4px, 0);
    }
    90% {
        transform: translate3d(0, -2px, 0);
    }
}

/* Empty state */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.125rem;
    pointer-events: none;
    user-select: none;
    animation: fadeIn 1s ease-out;
}

.empty-state h2 {
    margin-bottom: var(--spacing-md);
    font-weight: 300;
    font-size: 2rem;
}

.empty-state p {
    font-size: 1rem;
    opacity: 0.7;
    line-height: 1.5;
}

/* Notifications */
.notification {
    position: fixed;
    top: max(calc(var(--spacing-lg) + 40px), calc(env(safe-area-inset-top, 0px) + 40px));
    right: max(var(--spacing-lg), env(safe-area-inset-right, var(--spacing-lg)));
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    color: var(--white);
    font-weight: 500;
    z-index: var(--z-tooltip);
    transform: translateX(100%);
    transition: var(--transition-normal);
    max-width: 300px;
    box-shadow: var(--shadow-lg);
}

.notification.show {
    transform: translateX(0);
}

.notification-info {
    background: var(--info-color);
}

.notification-success {
    background: var(--success-color);
}

.notification-warning {
    background: var(--warning-color);
}

.notification-error {
    background: var(--error-color);
}

/* Context menu */
.context-menu {
    position: fixed;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    z-index: var(--z-dropdown);
    min-width: 150px;
    animation: fadeIn var(--transition-fast);
}

.menu-item {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.menu-item:hover {
    background: var(--gray-50);
}

.menu-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #noteCanvas {
        padding: var(--spacing-sm);
    }
    
    .content-block {
        max-width: calc(100vw - 20px);
        min-width: 80px;
        padding: var(--spacing-md);
        font-size: 0.9rem;
    }
    
    .block-header {
        font-size: 0.7rem;
    }
    
    .note-title {
        font-size: 0.9rem;
    }
    
    .empty-state h2 {
        font-size: 1.5rem;
    }
    
    .empty-state p {
        font-size: 0.9rem;
    }
    
    .notification {
        top: calc(var(--spacing-sm) + 40px);
        right: var(--spacing-sm);
        left: var(--spacing-sm);
        max-width: none;
    }
    
    .context-menu {
        min-width: 120px;
    }
    
    .menu-item {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .content-block {
        max-width: calc(100vw - 10px);
        min-width: 80px;
        padding: var(--spacing-sm);
    }
    
    .block-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
    
    .note-tags {
        gap: var(--spacing-xs);
    }
    
    .note-tag {
        font-size: 0.6rem;
        padding: 1px var(--spacing-xs);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .content-block {
        border: 2px solid var(--gray-800);
    }
    
    .content-block:hover {
        border-color: var(--primary-color);
    }
    
    .note-tag {
        border: 1px solid var(--primary-color);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .content-block {
        animation: none;
    }
    
    .loading-indicator {
        animation: none;
    }
}

/* Print styles */
@media print {
    .content-block {
        position: static;
        margin-bottom: var(--spacing-lg);
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
    
    .block-actions,
    .context-menu,
    .notification {
        display: none;
    }
}

/* Focus styles for accessibility */
.content-block:focus-visible {
    outline: 1px solid rgba(102, 126, 234, 0.35);
    outline-offset: 1px;
}

.action-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection styles */
::selection {
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(102, 126, 234, 0.2);
    color: var(--text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
} 
.block-content h5 { font-size: 14px; }
.block-content h6 { font-size: 12px; }

/* Auto List Styles */
.auto-list {
    margin: var(--spacing-sm) 0;
    padding: 0;
    list-style: none;
}

.list-item {
    position: relative;
    padding: var(--spacing-xs) 0;
    margin: 0;
    line-height: 1.5;
    min-height: 1.5em;
    outline: none;
    transition: background-color var(--transition-fast);
}

.list-item:focus {
    background-color: rgba(102, 126, 234, 0.05);
    border-radius: var(--radius-sm);
}

.list-item:focus::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--primary-color);
    border-radius: var(--radius-sm);
}

.list-item:empty::after {
    content: 'Type here...';
    color: var(--text-tertiary);
    font-style: italic;
    pointer-events: none;
}

/* Nested lists */
.list-item .auto-list {
    margin-left: var(--spacing-lg);
    margin-top: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
}

.list-item .list-item {
    padding-left: var(--spacing-sm);
}

/* List item indentation */
.list-item.indented {
    margin-left: var(--spacing-lg);
}

.list-item.indented::before {
    content: '◦ ';
    color: var(--text-tertiary);
    margin-right: var(--spacing-xs);
}

/* List item states */
.list-item.completed {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.list-item.completed::before {
    content: '✓ ';
    color: var(--success-color);
    margin-right: var(--spacing-xs);
}

/* List item animations */
.list-item {
    animation: listItemFadeIn var(--transition-normal);
}

@keyframes listItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* List item hover effects */
.list-item:hover {
    background-color: rgba(102, 126, 234, 0.02);
    border-radius: var(--radius-sm);
}

/* List item selection */
.list-item.selected {
    background-color: rgba(102, 126, 234, 0.1);
    border-radius: var(--radius-sm);
}

/* List item drag and drop */
.list-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.list-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

/* List item keyboard navigation */
.list-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* List item placeholder */
.list-item[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    font-style: italic;
    pointer-events: none;
}

/* List item bullet customization */
.list-item::before {
    content: '• ';
    color: var(--primary-color);
    margin-right: var(--spacing-xs);
    font-weight: bold;
}

/* Different bullet styles for different list types */
.list-item[data-list-type="dash"]::before {
    content: '– ';
}

.list-item[data-list-type="arrow"]::before {
    content: '→ ';
}

.list-item[data-list-type="check"]::before {
    content: '☐ ';
}

.list-item[data-list-type="check"].completed::before {
    content: '☑ ';
}

/* List item spacing and typography */
.list-item {
    font-size: 14px;
    color: var(--text-primary);
}

.list-item strong {
    font-weight: 600;
    color: var(--text-primary);
}

.list-item em {
    font-style: italic;
    color: var(--text-secondary);
}

.list-item code {
    background-color: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
}

/* List item links */
.list-item a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

.list-item a:hover {
    border-bottom-color: var(--primary-color);
}

/* List item responsive design */
@media (max-width: 768px) {
    .list-item {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: var(--spacing-sm) 0;
    }
    
    .list-item .auto-list {
        margin-left: var(--spacing-md);
    }
    
    .list-item.indented {
        margin-left: var(--spacing-md);
    }
}

/* List item dark theme support */
[data-theme="dark"] .list-item {
    color: var(--text-primary);
}

[data-theme="dark"] .list-item:focus {
    background-color: rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .list-item:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

[data-theme="dark"] .list-item code {
    background-color: var(--gray-700);
    color: var(--text-primary);
}

/* List item accessibility */
@media (prefers-reduced-motion: reduce) {
    .list-item {
        animation: none;
        transition: none;
    }
}

/* List item print styles */
@media print {
    .list-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .list-item:focus,
    .list-item:hover {
        background-color: transparent;
    }
}

/* Link Preview Styles */
.link-preview {
    margin: var(--spacing-md) 0;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: var(--white);
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.link-preview:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.link-preview-content {
    display: flex;
    align-items: flex-start;
    padding: var(--spacing-md);
    gap: var(--spacing-md);
}

.link-favicon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.link-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xs);
    font-size: 14px;
    line-height: 1.4;
}

.link-description {
    color: var(--gray-600);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: var(--spacing-xs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-url {
    color: var(--blue-600);
    font-size: 12px;
    font-family: var(--font-mono);
    word-break: break-all;
}

.link-image {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
}

.link-actions {
    display: flex;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.link-action-btn {
    background: none;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 12px;
}

.link-action-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.link-action-btn i {
    font-size: 12px;
}

/* Dark mode link previews */
@media (prefers-color-scheme: dark) {
    .link-preview {
        background: var(--gray-800);
        border-color: var(--gray-700);
    }
    
    .link-title {
        color: var(--gray-100);
    }
    
    .link-description {
        color: var(--gray-400);
    }
    
    .link-url {
        color: var(--blue-400);
    }
    
    .link-actions {
        background: var(--gray-900);
        border-color: var(--gray-700);
    }
    
    .link-action-btn:hover {
        background: var(--gray-700);
        color: var(--gray-200);
    }
}

/* Link preview responsive design */
@media (max-width: 768px) {
    .link-preview-content {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .link-image {
        width: 100%;
        height: 120px;
        align-self: center;
    }
    
    .link-actions {
        justify-content: center;
    }
}

/* Link preview print styles */
@media print {
    .link-preview {
        display: none !important;
    }
} /* Canvas Toolbar Styles */
.canvas-toolbar {
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: var(--ln-float-inset-right);
    display: flex;
    flex-direction: row;
    gap: var(--ln-float-gap);
    z-index: 1000;
    background: var(--ln-float-bg);
    backdrop-filter: var(--ln-float-backdrop);
    -webkit-backdrop-filter: var(--ln-float-backdrop);
    border-radius: var(--ln-float-radius);
    padding: var(--ln-float-pad);
    box-shadow: var(--ln-float-shadow);
    border: 1px solid var(--ln-float-border);
}

.toolbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ln-float-control-size);
    height: var(--ln-float-control-size);
    background: transparent;
    color: var(--ln-float-muted);
    border: none;
    border-radius: var(--ln-float-control-radius);
    font-size: var(--ln-float-icon);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-decoration: none;
}

.toolbar-icon:hover {
    background: var(--ln-float-hover);
    color: var(--ln-float-muted-strong);
    text-decoration: none;
}

.toolbar-icon:active {
    background: var(--ln-float-hover);
}

.toolbar-icon i {
    font-size: var(--ln-float-icon);
    line-height: 1;
    pointer-events: none;
}

.toolbar-icon .fas,
.toolbar-icon .fa-solid {
    font-weight: 900;
}

.toolbar-icon.home-icon:hover {
    background: var(--primary-color);
    color: white;
}

.toolbar-icon.clear-icon:hover {
    background: var(--error-color);
    color: white;
}

.toolbar-icon.history-icon:hover {
    background: var(--info-color);
    color: white;
}

.toolbar-icon.drawing-icon:hover {
    background: var(--secondary-color);
    color: white;
}

.toolbar-icon.drawing-icon.is-active {
    background: var(--primary-color);
    color: white;
}

.toolbar-icon.save-icon:hover {
    background: var(--success-color);
    color: white;
}

.toolbar-icon.sidebar-icon:hover {
    background: var(--info-color);
    color: white;
}

.toolbar-icon.agents-icon:hover {
    background: var(--primary-color);
    color: white;
}

.canvas-agents-panel {
    position: fixed;
    top: max(72px, calc(env(safe-area-inset-top, 0px) + 52px));
    right: max(20px, env(safe-area-inset-right, 20px));
    z-index: 1001;
    max-width: min(420px, calc(100vw - 40px));
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
}

.canvas-agents-panel[hidden] {
    display: none !important;
}

.canvas-agents-target-hint {
    margin: 0 0 10px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.canvas-agents-target-hint[hidden] {
    display: none !important;
}

.canvas-chat-sidebar.canvas-nav-panel {
    z-index: 10051;
}

#chatDrawerBackdrop.canvas-nav-backdrop {
    z-index: 10048;
}

.canvas-chat-sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ln-sidebar-title, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.canvas-chat-sidebar-body {
    min-height: 100%;
    padding: 12px;
}

.canvas-chat-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: -2px -2px 10px;
    padding: 2px 2px 10px;
    border-bottom: 1px solid var(--ln-sidebar-border, #e6e9ef);
}

.canvas-chat-sidebar-head h2 {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ln-sidebar-title, #6b7280);
    font-weight: 600;
}

.canvas-chat-sidebar-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--ln-sidebar-card-border, #d1d5db);
    border-radius: 10px;
    background: var(--ln-sidebar-card-bg, #f9fafb);
    color: #475569;
    cursor: pointer;
    line-height: 1;
    font-size: 20px;
    flex-shrink: 0;
}

.canvas-chat-sidebar-close:hover {
    background: var(--ln-sidebar-card-hover, #f1f5f9);
    border-color: var(--ln-sidebar-card-hover-border, #cbd5e1);
    color: #111827;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal.show,
.modal[style*="block"] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-xl);
    overflow-y: auto;
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* History Modal Styles */
.history-modal .modal-content {
    max-width: 600px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.history-modal-body {
    overflow-y: auto;
    max-height: 55vh;
    padding: 4px 0;
}

.history-empty {
    color: var(--text-secondary);
    padding: 12px 8px;
    margin: 0;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.history-item:last-child {
    margin-bottom: 0;
}

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

.history-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.history-meta {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-bottom: 2px;
}

.history-archived {
    color: var(--warning-color, #d97706);
    font-weight: 500;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-chevron {
    flex-shrink: 0;
    color: var(--gray-400);
    font-size: 0.85rem;
}

.history-notes {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Shortcuts Modal Styles */
.shortcuts-modal .modal-content {
    max-width: 600px;
    max-height: 80vh;
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    transition: var(--transition-fast);
}

.shortcut-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--gray-300);
}

.shortcut-key {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--gray-100);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    min-width: 120px;
    text-align: center;
}

.shortcut-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    flex: 1;
    margin-left: var(--spacing-lg);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .canvas-toolbar {
        top: max(10px, env(safe-area-inset-top, 10px));
        padding: 6px;
        gap: 6px;
    }

    .toolbar-icon {
        width: 44px;
        height: 44px;
        font-size: 16px;
        touch-action: manipulation;
    }

    .toolbar-icon i {
        font-size: 16px;
    }

    .modal-close {
        width: 44px;
        height: 44px;
    }
}

/* Touch-device active states (supplement hover-only feedback) */
.toolbar-icon:active {
    background: var(--ln-float-hover);
}
.action-btn:active {
    opacity: 1;
    background: var(--gray-100);
}

/* ============================================================================
   Link Notes Styles
   ============================================================================ */

/* Link note container (same card constraints as user notes; hard max via .card-layout-manual) */
.content-block.link-note {
    min-width: 80px;
    max-width: 600px;
}

.content-block.link-note.card-layout-manual {
    max-width: 1000px;
}

/* Link preview card */
/* Link preview card — compact: thumbnail (40px) left, title + domain right */
.link-preview-card {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
    border-radius: 6px;
}

.lp-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
}

.lp-thumb img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.lp-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lp-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    text-decoration: none;
}

.lp-title:hover {
    text-decoration: underline;
}

.lp-domain {
    font-size: 11px;
    opacity: 0.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.ln-note-input-rail > .link-note-user-text {
    outline: none;
    padding: 4px 8px 6px;
    font-size: 13px;
    line-height: 1.5;
    min-height: 1.5em;
    word-break: break-word;
}

.link-note-user-text[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary, rgba(107, 114, 128, 0.5));
    pointer-events: none;
}

/* Link note in list view (for notes list page) */
.note-item.link-note {
    display: flex;
    flex-direction: column;
}

.note-item.link-note .note-preview {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.note-item.link-note .note-preview-thumbnail {
    width: 120px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.note-item.link-note .note-preview-content {
    flex: 1;
    min-width: 0;
}

.note-item.link-note .note-preview-title {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.note-item.link-note .note-preview-site {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-xs);
}

.note-item.link-note .note-preview-snippet {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* -------------------------------------------------------------------------
   Per-block command console: history + input. Zone max-height 60px; history scrolls.
   Pin > + input to the bottom of the zone.
   ------------------------------------------------------------------------- */

/* Stack note + console; free space sits above the command row */
.content-block:has(.block-command-zone) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.content-block:has(.block-command-zone) .block-command-zone {
    margin-top: auto;
    flex-shrink: 0;
}

/* Note column: flexes between card chrome and command zone; affordances live inside the rail, not this row */
.ln-note-input-rail {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    flex: 1;
}

.ln-note-input-rail > .block-note-body {
    margin-top: 7px;
}

.content-block:has(.block-command-zone) > .ln-note-input-rail {
    flex: 1 1 auto;
    min-width: 0;
}

.content-block.link-note:has(> .ln-note-input-rail) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/*
 * Horizontal bleed: card padding (--ln-card-inline-pad from JS, else 14px) left a wide empty band beside text.
 * Pull the note rail (and command zone) inward to leave a small inset from the card border only.
 */
.content-block.user > .ln-note-input-rail,
.content-block.link-note > .ln-note-input-rail {
    --ln-note-rail-bleed: max(0px, calc(var(--ln-card-inline-pad, 14px) - 6px));
    margin-left: calc(-1 * var(--ln-note-rail-bleed));
    margin-right: calc(-1 * var(--ln-note-rail-bleed));
    width: calc(100% + 2 * var(--ln-note-rail-bleed));
    max-width: none;
    box-sizing: border-box;
}

.content-block.user > .block-command-zone {
    --ln-note-rail-bleed: max(0px, calc(var(--ln-card-inline-pad, 14px) - 6px));
    margin-left: calc(-1 * var(--ln-note-rail-bleed));
    margin-right: calc(-1 * var(--ln-note-rail-bleed));
    width: calc(100% + 2 * var(--ln-note-rail-bleed));
    max-width: none;
    box-sizing: border-box;
}

/* User-resized height: scroll the note only; keep console visible at bottom */
.content-block.card-layout-manual.user:has(.block-command-zone) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-block.card-layout-manual.user:has(.block-command-zone) > .ln-note-input-rail {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.content-block.card-layout-manual.user:has(.block-command-zone) > .ln-note-input-rail > .block-note-body {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

/* --- Media layers: image + drawing above note text --- */
/* Both layers are passive visual content — cards drag and resize normally. */
.ln-note-media-stack {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: block;
    height: 90px;
    margin-bottom: 6px;
    border-radius: 6px;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
}

.ln-note-image,
.ln-note-drawing {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: block;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0;
    /* Passive: pass all pointer events through to the card drag/resize handlers */
    pointer-events: none;
    user-select: none;
}

.ln-note-media-stack .ln-note-drawing--overlay,
.lp-thumb .ln-note-drawing--overlay {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    z-index: 1;
    pointer-events: none;
}

.lp-thumb.ln-has-drawing-overlay {
    position: relative;
}

/* Image and drawing previews: hard 90px height — no percentage resolution needed. */
.ln-note-media-stack,
.ln-note-image,
.ln-note-drawing {
    height: 90px;
}

.lp-thumb .ln-note-drawing--overlay {
    height: 100%;
}

.ln-note-image-img,
.ln-note-drawing img,
.ln-note-drawing svg {
    width: 100%;
    height: 90px;
    display: block;
    border-radius: 4px;
    object-fit: cover;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.ln-note-media-stack .ln-note-drawing--overlay img,
.lp-thumb .ln-note-drawing--overlay img {
    height: 100%;
    object-fit: contain;
}

.ln-note-image--load-failed {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
}

.ln-note-image-fallback {
    font-size: 12px;
    color: var(--ln-muted-text, #6b7280);
    padding: 8px 12px;
    text-align: center;
}

/* Drawing edit mode: activated explicitly by JS (add ln-drawing-edit class) — not always */
.content-block.ln-drawing-edit > .ln-note-input-rail > .ln-note-drawing {
    pointer-events: auto;
    cursor: crosshair;
}

/* Legacy blocks (no rail yet): same scroll behavior on the body */
.content-block.card-layout-manual.user:has(.block-command-zone) > .block-note-body {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Manual height: command zone input row never clipped */
.content-block.card-layout-manual.user:has(.block-command-zone) .block-command-zone {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.content-block.card-layout-manual.user:has(.block-command-zone) .block-command-input-row {
    flex-shrink: 0;
}

.block-command-zone {
    border-top: 1px solid var(--gray-200);
    margin-top: 0;
    padding-top: 2px;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    transition: color var(--transition-fast), border-color var(--transition-fast);
    min-height: 32px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.block-command-zone .block-command-console {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
}

.block-command-zone .block-command-input-row {
    flex-shrink: 0;
    min-height: 22px;
    margin-top: 0;
}

.block-command-zone .block-command-line-field {
    padding: 1px 4px;
    border-radius: 4px;
}

.block-command-zone .block-command-line {
    height: 22px;
    min-height: 22px;
    max-height: 22px;
    box-sizing: border-box;
    padding: 1px 3px;
    font-size: 0.7rem;
    line-height: 1.2;
    overflow-y: auto;
}

[data-theme="dark"] .block-command-zone {
    border-top-color: var(--gray-600);
}

.block-command-console {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 1.75rem;
}

.block-command-input-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding-bottom: 0;
    margin-top: 1px;
}

.block-command-input-row .block-command-ai-btn {
    margin-top: 3px;
}

.block-command-ai-btn {
    flex-shrink: 0;
    margin: 0;
    padding: 2px 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-tertiary);
    cursor: pointer;
    font-family: inherit;
}

.block-command-ai-btn:hover {
    color: var(--text-secondary);
    border-color: var(--gray-400);
}

[data-theme="dark"] .block-command-ai-btn {
    border-color: var(--gray-600);
}

.block-command-line-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .block-command-line-field {
    background: rgba(255, 255, 255, 0.06);
}

.block-command-line {
    flex: 1;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    display: block;
    border: none;
    background: transparent;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--text-secondary);
    padding: 4px 2px;
    outline: none;
    resize: none;
    max-height: 120px;
    /* Hidden until JS sets overflow:auto when content exceeds max height */
    overflow-y: hidden;
    overflow-x: hidden;
    vertical-align: top;
}

.block-command-line::placeholder {
    color: var(--text-tertiary);
    opacity: 0.85;
}

.content-block.command-zone-focused .block-command-zone {
    color: var(--text-secondary);
}

.content-block.command-zone-focused .block-command-line {
    color: var(--text-primary);
}

/* Command & tag dropdowns */
.lifenotes-cmd-dropdown,
.lifenotes-tag-dropdown {
    position: fixed;
    z-index: var(--z-popover);
    min-width: 220px;
    max-width: min(360px, 92vw);
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
}

[data-theme="dark"] .lifenotes-cmd-dropdown,
[data-theme="dark"] .lifenotes-tag-dropdown {
    border-color: var(--gray-600);
}

.lifenotes-cmd-dd-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.lifenotes-cmd-dd-item:hover,
.lifenotes-cmd-dd-item.ln-cmd-dd-active {
    background: var(--gray-100);
}

[data-theme="dark"] .lifenotes-cmd-dd-item:hover,
[data-theme="dark"] .lifenotes-cmd-dd-item.ln-cmd-dd-active {
    background: var(--gray-700);
}

.lifenotes-cmd-dd-hint {
    padding: 8px 12px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.lifenotes-cmd-dd-footer {
    border-top: 1px solid var(--gray-200);
    margin-top: 4px;
    padding-top: 4px;
}

.lifenotes-cmd-dd-see-all {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: none;
    font-size: 0.8125rem;
    color: var(--primary-color);
    cursor: pointer;
}

.lifenotes-cmd-dd-see-all:hover {
    text-decoration: underline;
}

/* Cards with AI thread history (additive messages region; persistent strip at card bottom). */
.content-block[data-ln-ai-thread="1"] {
    min-width: min(560px, 92vw);
}

.content-block[data-ln-ai-thread="1"] .block-ai-thread-messages,
.content-block[data-ln-ai-thread="1"] .block-ai-thread-msg {
    user-select: text;
    -webkit-user-select: text;
}

.content-block[data-ln-ai-thread="1"] .block-ai-thread-messages:focus {
    outline: none;
}

.content-block[data-ln-ai-thread="1"] .block-ai-thread-messages:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.block-note-body strong {
    font-weight: 700;
}

.block-note-body ul,
.block-note-body ol {
    margin: 6px 0 6px 20px;
    padding-left: 14px;
}

.block-note-body li {
    margin: 2px 0;
}

/* Thread messages sit in the rail after note body; hidden until populated. */
.ln-note-input-rail > .block-ai-thread-messages {
    flex-shrink: 0;
    border-top: 1px solid var(--gray-200);
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-xs);
}

[data-theme="dark"] .ln-note-input-rail > .block-ai-thread-messages {
    border-top-color: var(--gray-600);
}

/* Manual-height card: scroll messages inside rail; command strip stays pinned on card. */
.content-block.card-layout-manual.user:has(.block-ai-thread-messages:not(:empty)) > .ln-note-input-rail {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.content-block.card-layout-manual.user:has(.block-ai-thread-messages:not(:empty)) > .ln-note-input-rail > .block-note-body {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 45%;
    overflow-x: hidden;
    overflow-y: auto;
}

.content-block.card-layout-manual.user:has(.block-ai-thread-messages:not(:empty)) > .ln-note-input-rail > .block-ai-thread-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

.block-ai-thread-messages {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.7rem;
    line-height: 1.45;
}

.block-ai-thread-messages:empty {
    display: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none;
}

.block-ai-thread-msg {
    padding: 8px 10px;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.35;
}

.block-ai-thread-msg-user {
    background: var(--gray-100);
    align-self: flex-end;
    max-width: 92%;
}

.block-ai-thread-msg-assistant {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    align-self: flex-start;
    max-width: 100%;
}

.block-ai-thread-msg-rich {
    white-space: normal;
}

.block-ai-thread-msg-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.block-ai-thread-msg-text strong {
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.block-ai-thread-msg-text-mixed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.block-ai-thread-msg-pre {
    margin: 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    background: var(--surface-muted, #f3f4f6);
    overflow-x: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.block-ai-thread-msg-code {
    display: block;
    margin: 0;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre;
    color: var(--text-primary, #111827);
    background: transparent;
}

.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-table-wrap,
.block-ai-thread-msg-rich .block-ai-thread-table-wrap + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-table-wrap + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-table-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-table-wrap + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-table-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-msg-text-mixed + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-msg-text-mixed,
.block-ai-thread-msg-rich .block-ai-thread-msg-text-mixed + .block-ai-thread-table-wrap,
.block-ai-thread-msg-rich .block-ai-thread-table-wrap + .block-ai-thread-msg-text-mixed,
.block-ai-thread-msg-rich .block-ai-thread-msg-text-mixed + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-msg-text-mixed,
.block-ai-thread-msg-rich .block-ai-thread-msg-text-mixed + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-msg-text-mixed,
.block-ai-thread-msg-rich .block-ai-thread-msg-text + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-msg-text,
.block-ai-thread-msg-rich .block-ai-thread-table-wrap + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-table-wrap,
.block-ai-thread-msg-rich .block-ai-thread-list-wrap + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-list-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-pullquote + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-pullquote,
.block-ai-thread-msg-rich .block-ai-thread-msg-text-mixed + .block-ai-thread-checklist-wrap,
.block-ai-thread-msg-rich .block-ai-thread-checklist-wrap + .block-ai-thread-msg-text-mixed {
    margin-top: 8px;
}

/* Quotes & scripture (AI thread) */
blockquote.block-ai-thread-pullquote {
    margin: 0;
    padding: 0;
    border: 0;
}

.block-ai-thread-pullquote {
    position: relative;
    border-radius: 10px;
    padding: 12px 14px 12px 16px;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--surface-primary, #fff) 55%);
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.block-ai-thread-pullquote--quote::before {
    content: '"';
    position: absolute;
    left: 10px;
    top: 6px;
    font-size: 2rem;
    line-height: 1;
    font-family: Georgia, 'Times New Roman', serif;
    color: color-mix(in srgb, var(--primary-color, #2563eb) 35%, var(--gray-300));
    opacity: 0.9;
    pointer-events: none;
}

.block-ai-thread-pullquote--scripture {
    background: linear-gradient(135deg, rgba(180, 140, 60, 0.08) 0%, var(--surface-primary, #fff) 50%);
    border-color: rgba(180, 140, 60, 0.35);
    padding-left: 18px;
}

.block-ai-thread-pullquote--scripture::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 10px 0 0 10px;
    background: linear-gradient(180deg, #c4a35a 0%, #a67c3a 100%);
    pointer-events: none;
}

.block-ai-thread-pullquote-text {
    position: relative;
    z-index: 1;
    margin: 0;
    padding-left: 0.35rem;
    font-family: Georgia, 'Palatino Linotype', Palatino, 'Times New Roman', serif;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.block-ai-thread-pullquote--scripture .block-ai-thread-pullquote-text {
    padding-left: 0.5rem;
}

.block-ai-thread-pullquote-attrib {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.block-ai-thread-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--surface-primary, #fff);
}

.block-ai-thread-table {
    min-width: max-content;
    display: table;
    border-collapse: collapse;
    width: 100%;
}

.block-ai-thread-table-row {
    display: table-row;
}

.block-ai-thread-table-cell {
    display: table-cell;
    padding: 6px 8px;
    border-bottom: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    vertical-align: top;
    white-space: nowrap;
}

.block-ai-thread-table-row-head .block-ai-thread-table-cell {
    font-weight: 600;
    background: var(--gray-100);
}

.block-ai-thread-table-row .block-ai-thread-table-cell:last-child {
    border-right: 0;
}

.block-ai-thread-table-row:last-child .block-ai-thread-table-cell {
    border-bottom: 0;
}

/* Structured query results: list / cards */
.block-ai-thread-list-wrap {
    border-radius: 10px;
    overflow: hidden;
}

.block-ai-thread-list-heading {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding: 0 2px;
}

.block-ai-thread-list-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.block-ai-thread-list-item {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--surface-primary, #fff);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.block-ai-thread-list-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(180deg, var(--gray-50) 0%, var(--gray-100) 100%);
    border-bottom: 1px solid var(--gray-200);
}

.block-ai-thread-list-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary-color, #2563eb);
    background: color-mix(in srgb, var(--primary-color, #2563eb) 12%, transparent);
}

.block-ai-thread-list-type {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-secondary);
    word-break: break-all;
}

.block-ai-thread-list-fields {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.block-ai-thread-list-field {
    display: grid;
    grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    padding: 4px 0;
    border-bottom: 1px dashed var(--gray-200);
}

.block-ai-thread-list-field:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.block-ai-thread-list-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    word-break: break-word;
}

.block-ai-thread-list-value {
    font-size: 0.75rem;
    color: var(--text-primary);
    word-break: break-word;
    white-space: pre-wrap;
}

.block-ai-thread-list-empty {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 4px 0;
}

/* Structured query results: checklist (tasks / todos) */
.block-ai-thread-checklist-wrap {
    border-radius: 10px;
    overflow: hidden;
}

.block-ai-thread-checklist-heading {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding: 0 2px;
}

.block-ai-thread-checklist-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.block-ai-thread-checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--surface-primary, #fff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.block-ai-thread-checklist-cb-wrap {
    flex-shrink: 0;
    padding-top: 2px;
}

.block-ai-thread-checklist-cb {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color, #667eea);
}

.block-ai-thread-checklist-cb:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.block-ai-thread-checklist-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.block-ai-thread-checklist-title {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    word-break: break-word;
}

.block-ai-thread-checklist-status {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.block-ai-thread-checklist-status:empty {
    display: none;
}

.block-ai-thread-checklist-item--complete .block-ai-thread-checklist-title {
    text-decoration: line-through;
    opacity: 0.78;
}

.block-ai-thread-checklist-extras {
    font-size: 0.68rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.block-ai-thread-msg-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    opacity: 0.95;
}

.block-ai-thread-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}

.block-ai-thread-loading-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.35;
}

/* Block-local scrollbars: thinner, light blue */
.content-block,
.block-note-body,
.block-ai-thread-note-text,
.block-ai-thread-messages,
.block-command-line {
    scrollbar-width: thin;
    scrollbar-color: rgba(147, 197, 253, 0.35) transparent;
}

.content-block::-webkit-scrollbar,
.block-note-body::-webkit-scrollbar,
.block-ai-thread-note-text::-webkit-scrollbar,
.block-ai-thread-messages::-webkit-scrollbar,
.block-command-line::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

.content-block::-webkit-scrollbar-track,
.block-note-body::-webkit-scrollbar-track,
.block-ai-thread-note-text::-webkit-scrollbar-track,
.block-ai-thread-messages::-webkit-scrollbar-track,
.block-command-line::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 999px;
}

.content-block::-webkit-scrollbar-thumb,
.block-note-body::-webkit-scrollbar-thumb,
.block-ai-thread-note-text::-webkit-scrollbar-thumb,
.block-ai-thread-messages::-webkit-scrollbar-thumb,
.block-command-line::-webkit-scrollbar-thumb {
    background: rgba(147, 197, 253, 0.35);
    border-radius: 999px;
}

.content-block::-webkit-scrollbar-thumb:hover,
.block-note-body::-webkit-scrollbar-thumb:hover,
.block-ai-thread-note-text::-webkit-scrollbar-thumb:hover,
.block-ai-thread-messages::-webkit-scrollbar-thumb:hover,
.block-command-line::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.55);
}

[data-theme="dark"] .block-ai-thread-msg-user {
    background: var(--gray-800);
}

[data-theme="dark"] .block-ai-thread-msg-assistant {
    background: var(--gray-800);
    border-color: var(--gray-600);
}

[data-theme="dark"] .block-ai-thread-table-wrap {
    border-color: var(--gray-600);
    background: var(--gray-850, #171b24);
}

[data-theme="dark"] .block-ai-thread-table-cell {
    border-color: var(--gray-700);
}

[data-theme="dark"] .block-ai-thread-table-row-head .block-ai-thread-table-cell {
    background: var(--gray-750, #2a3343);
}

[data-theme="dark"] .block-ai-thread-list-item {
    border-color: var(--gray-600);
    background: var(--gray-850, #171b24);
    box-shadow: none;
}

[data-theme="dark"] .block-ai-thread-list-item-head {
    background: linear-gradient(180deg, var(--gray-800) 0%, var(--gray-850, #171b24) 100%);
    border-bottom-color: var(--gray-600);
}

[data-theme="dark"] .block-ai-thread-list-field {
    border-bottom-color: var(--gray-700);
}

[data-theme="dark"] .block-ai-thread-list-index {
    background: color-mix(in srgb, var(--primary-color, #60a5fa) 18%, transparent);
    color: var(--primary-color, #93c5fd);
}

[data-theme="dark"] .block-ai-thread-pullquote {
    background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-850, #171b24) 60%);
    border-color: var(--gray-600);
    box-shadow: none;
}

[data-theme="dark"] .block-ai-thread-pullquote--scripture {
    background: linear-gradient(135deg, rgba(196, 163, 90, 0.12) 0%, var(--gray-850, #171b24) 55%);
    border-color: rgba(196, 163, 90, 0.4);
}

[data-theme="dark"] .block-ai-thread-pullquote-attrib {
    border-top-color: var(--gray-600);
}

.content-block[data-ln-ai-thread="1"] .block-note-body.ln-ai-thread-hidden {
    display: none !important;
}

/* Clickable #tags — custom accent (not default browser link blue), no underline */
.ln-inline-tag {
    --ln-tag-link: var(--ln-note-link);
    --ln-tag-link-hover: var(--ln-note-link-hover);
    color: var(--ln-tag-link);
    cursor: pointer;
    text-decoration: none;
    border-radius: 3px;
    font-weight: 600;
}

.ln-inline-tag:hover {
    color: var(--ln-tag-link-hover);
}

.block-note-body a:not(.ln-inline-tag),
.block-ai-thread-note-text a:not(.ln-inline-tag),
.link-note-user-text a:not(.ln-inline-tag) {
    color: var(--ln-note-link);
}

.block-note-body a:not(.ln-inline-tag):hover,
.block-ai-thread-note-text a:not(.ln-inline-tag):hover,
.link-note-user-text a:not(.ln-inline-tag):hover {
    color: var(--ln-note-link-hover);
}

/* Command palette: full list */
.ln-palette-list {
    max-height: 240px;
    overflow-y: auto;
    border-top: 1px solid var(--gray-200);
    margin-top: 8px;
    padding-top: 4px;
}

.ln-palette-list-item {
    padding: 6px 12px;
    font-size: 0.8125rem;
    cursor: pointer;
    color: var(--text-primary);
}

.ln-palette-list-item:hover {
    background: var(--gray-100);
}

.block-ai-inline-panel {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    border-top: 1px dashed var(--gray-200);
    white-space: pre-wrap;
    word-break: break-word;
}

.ln-command-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.ln-command-palette {
    width: min(420px, 92vw);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    padding: var(--spacing-md);
}

[data-theme="dark"] .ln-command-palette {
    border-color: var(--gray-600);
}

.ln-palette-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9375rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.ln-palette-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 8px;
}

/* Primary goal panel (object layer) */
.ln-goal-panel {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 8px 10px;
    border-top: 1px dashed var(--gray-200);
    background: var(--gray-50);
}

[data-theme="dark"] .ln-goal-panel {
    background: rgba(15, 23, 42, 0.5);
    border-top-color: var(--gray-600);
}

.ln-goal-panel.ln-goal-panel--thread {
    margin-top: 50px;
    margin-bottom: 8px;
    border-top: 0;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--surface-primary, #fff);
}

[data-theme="dark"] .ln-goal-panel.ln-goal-panel--thread {
    border-color: var(--gray-600);
    background: rgba(15, 23, 42, 0.45);
}

.ln-goal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ln-goal-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ln-goal-pause-btn {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-300);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.ln-goal-stats {
    font-size: 0.75rem;
    margin-bottom: 8px;
    color: var(--text-tertiary);
}

.ln-goal-paused-banner {
    font-size: 0.75rem;
    color: var(--warning-color);
    margin-bottom: 6px;
}

.ln-goal-check-row {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-bottom: 6px;
}

.ln-goal-done-cb {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.ln-goal-done-cb:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.ln-goal-period-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ln-goal-period-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

.ln-goal-period-input {
    min-width: 170px;
    padding: 5px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.ln-goal-numeric-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ln-goal-numeric-row label {
    width: 100%;
    font-size: 0.75rem;
}

.ln-goal-num-input {
    flex: 1;
    min-width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.ln-goal-save-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--primary-color);
    color: var(--white);
    cursor: pointer;
}

.ln-goal-save-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ln-goal-inline-feedback {
    margin-top: 4px;
    margin-bottom: 8px;
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.ln-goal-inline-feedback[data-tone="pending"] {
    color: var(--text-tertiary);
}

.ln-goal-inline-feedback[data-tone="success"] {
    color: var(--success-color, #16a34a);
}

.ln-goal-inline-feedback[data-tone="error"] {
    color: var(--danger-color, #dc2626);
}

.ln-goal-custom-wrap {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--gray-300);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

[data-theme="dark"] .ln-goal-custom-wrap {
    border-top-color: var(--gray-600);
}

.ln-goal-custom-heading {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ln-goal-custom-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ln-goal-custom-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.ln-goal-custom-input {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.ln-goal-custom-input-bool {
    width: 1rem;
    height: 1rem;
    padding: 0;
    accent-color: var(--primary-color, #667eea);
}

.ln-goal-custom-save-btn {
    align-self: flex-start;
}

.ln-goal-notes {
    width: 100%;
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 0.8125rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
}

.ln-goal-loading,
.ln-goal-error {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.ln-goal-checklist-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Query canvas: fixed-height compact cards (tail below 3×4 grid) */
.content-block.user.ln-query-card--compact,
.content-block.link-note.ln-query-card--compact {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.content-block.user.ln-query-card--compact > .ln-note-input-rail {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.content-block.user.ln-query-card--compact > .ln-note-input-rail > .block-note-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.content-block.user.ln-query-card--compact > .block-note-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.content-block[data-ln-ai-thread="1"].ln-query-card--compact {
    display: flex;
    flex-direction: column;
}

.content-block[data-ln-ai-thread="1"].ln-query-card--compact .block-ai-thread-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.content-block.link-note.ln-query-card--compact > .ln-note-input-rail {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.content-block.link-note.ln-query-card--compact > .ln-note-input-rail > .link-preview-card {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.content-block.link-note.ln-query-card--compact .link-preview-card {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.content-block.link-note.ln-query-card--compact .link-preview-image img {
    max-height: 56px;
    object-fit: cover;
}

.content-block.ln-query-card--compact .block-command-zone {
    flex-shrink: 0;
}

.content-block.user.ln-query-card--compact .ln-goal-card {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* --- Card affordances: Agents → Tasks → Tags (top-right, compact; body padding-right matches strip width) --- */
.ln-card-affordances {
    position: absolute;
    top: 0px;
    right: 10px;
    z-index: 2;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    flex-wrap: nowrap;
    pointer-events: none;
    /* Fixed intrinsic width: strip does not participate in flex layout of the card (position:absolute) */
    width: max-content;
    max-width: min(240px, calc(100% - 20px));
    box-sizing: border-box;
}

/* Hosted inside .ln-note-input-rail: overlay the text column only (not laid out with .block-command-zone) */
.ln-note-input-rail > .ln-card-affordances {
    top: -3px;
    right: 4px;
    left: auto;
}

.content-block.card--compact .ln-card-affordances {
    gap: 2px;
    right: 8px;
    top: -7px;
}

.content-block.card--compact .ln-note-input-rail > .ln-card-affordances {
    right: 3px;
    top: -10px;
}

.ln-card-aff-btn {
    pointer-events: auto;
    box-sizing: border-box;
    min-width: 18px;
    min-height: 18px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition:
        border-radius 120ms ease,
        width 120ms ease,
        max-width 120ms ease,
        transform 120ms ease,
        padding 120ms ease,
        gap 120ms ease,
        box-shadow 120ms ease;
}

.ln-card-aff-btn:focus-visible {
    outline: 2px solid var(--primary-color, #667eea);
    outline-offset: 2px;
}

.ln-card-aff-btn:hover,
.ln-card-aff-btn:focus-visible {
    transform: scale(1.05);
}

.ln-card-aff-vis {
    --aff-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: var(--aff-size);
    height: var(--aff-size);
    max-width: 72px;
    padding: 0 2px;
    border-radius: 50%;
    border: 1px solid var(--gray-300, #d1d5db);
    background: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-secondary, #4b5563);
}

.ln-card-aff-btn--pill .ln-card-aff-vis {
    border-radius: 999px;
    padding: 0 3px;
}

.ln-card-aff-btn--annotate .ln-card-aff-vis {
    font-size: 9px;
    line-height: 1;
    font-weight: 700;
    color: var(--text-secondary, #4b5563);
}

.ln-card-aff-btn--annotate.ln-card-aff-btn--has .ln-card-aff-vis,
.ln-card-aff-btn--annotate:hover .ln-card-aff-vis {
    color: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
}

.ln-card-aff-btn--agents .ln-card-aff-vis {
    border-color: rgba(129, 140, 248, 0.55);
}

.ln-card-aff-btn--agents.ln-card-aff-btn--has .ln-card-aff-vis {
    background: rgba(129, 140, 248, 0.2);
}

.ln-card-aff-spark {
    display: block;
    font-size: 8px;
    line-height: 1;
    opacity: 0.85;
}

.ln-card-aff-btn--agents.ln-card-aff-btn--multi .ln-card-aff-vis {
    background: rgba(148, 163, 184, 0.35);
    border-color: rgba(148, 163, 184, 0.8);
}

.ln-card-aff-btn--tasks .ln-card-aff-vis {
    border-width: 1px;
}

.ln-card-aff-btn--tasks.ln-card-aff--prio-none .ln-card-aff-vis {
    background: transparent;
    border-color: var(--gray-300, #d1d5db);
}

.ln-card-aff-btn--tasks.ln-card-aff--prio-complete .ln-card-aff-vis {
    background: rgba(34, 197, 94, 0.35);
    border-color: rgba(22, 163, 74, 0.65);
}

.ln-card-aff-btn--tasks.ln-card-aff--prio-active .ln-card-aff-vis {
    background: rgba(234, 179, 8, 0.38);
    border-color: rgba(202, 138, 4, 0.75);
}

.ln-card-aff-btn--tasks.ln-card-aff--prio-overdue .ln-card-aff-vis {
    background: rgba(248, 113, 113, 0.4);
    border-color: rgba(220, 38, 38, 0.75);
}

.ln-card-aff-btn--tags .ln-card-aff-vis {
    border-color: var(--gray-300, #d1d5db);
}

.ln-card-aff-btn--tags.ln-card-aff-btn--has .ln-card-aff-vis {
    background: rgba(148, 163, 184, 0.35);
}

/*
 * Affordance strip is position:absolute (out of flow). Typing surfaces fill the rail; padding-inline-end
 * only clears text from under the overlay cluster.
 * AI thread: reserve on .block-ai-thread-note-text only (not on .ln-ai-thread-body) to avoid double padding.
 */
.content-block.user:has(.block-command-zone) > .ln-note-input-rail,
.content-block.user:has(.block-command-zone) > .block-note-body {
    min-width: 0;
}

.content-block.ln-card-aff--on .block-note-body,
.content-block.ln-card-aff--on .block-ai-thread-note-text,
.content-block.ln-card-aff--on .link-preview-card,
.content-block.ln-card-aff--on .link-note-user-text {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    padding-right: 6px;
}

.content-block.ln-card-aff--on .block-note-body {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    padding-right: 0;
}

.content-block.ln-card-aff--on.card--compact .block-note-body,
.content-block.ln-card-aff--on.card--compact .block-ai-thread-note-text,
.content-block.ln-card-aff--on.card--compact .link-preview-card,
.content-block.ln-card-aff--on.card--compact .link-note-user-text {
    padding-right: 4px;
}

/* Anchored popover */
#ln-card-aff-popover {
    position: fixed;
    z-index: 4000;
    width: min(300px, calc(100vw - 24px));
    max-height: min(320px, 55vh);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-xl, 0 12px 40px rgba(0, 0, 0, 0.15));
    overflow: hidden;
}

#ln-card-aff-popover[hidden] {
    display: none !important;
}

.ln-card-aff-pop-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    font-size: 0.8125rem;
    font-weight: 600;
}

.ln-card-aff-pop-bd {
    padding: 8px 10px;
    overflow-y: auto;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.ln-card-aff-pop-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.ln-card-aff-pop-row:last-child {
    border-bottom: none;
}

.ln-card-aff-pop-meta {
    font-size: 0.72rem;
    color: var(--text-tertiary, #9ca3af);
    margin-top: 2px;
}

.ln-card-aff-pop-actions {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
}

.ln-card-aff-pop-actions button {
    font-size: 0.7rem;
    padding: 2px 6px;
}

.ln-card-aff-pop-empty {
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.78rem;
}

.ln-card-aff-pop-help {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary, #4b5563);
}

/* Cron-driven scheduled job results (single panel per page) */
.ln-scheduled-results-panel {
    overflow: hidden;
}
.ln-scheduled-results-panel .ln-scheduled-results-body {
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text-secondary, #374151);
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}
.ln-scheduled-result-line {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}
.ln-scheduled-result-line:last-child {
    border-bottom: none;
}
.ln-scheduled-result-ul {
    margin: 0;
    padding-left: 1.25rem;
}
.ln-scheduled-result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.ln-scheduled-result-table th,
.ln-scheduled-result-table td {
    border: 1px solid var(--gray-200, #e5e7eb);
    padding: 4px 6px;
    text-align: left;
}
.ln-scheduled-result-p {
    margin: 0;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.ln-scheduled-result-ul li,
.ln-scheduled-result-table td,
.ln-scheduled-result-table th {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ============================================================================
   Mobile / Touch — safe-area, text-selection guards, tap target fixes
   ============================================================================ */

/* Prevent long-press callout and accidental text selection on interaction surfaces */
.canvas-toolbar,
.content-block:not([contenteditable="true"]) .block-header,
.content-block:not([contenteditable="true"]) .block-actions {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Modal safe-area and keyboard awareness */
@supports (padding: env(safe-area-inset-bottom)) {
    .modal.show,
    .modal[style*="block"] {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .modal-content {
        max-height: calc(90vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    }
}

/* ---- Cloud file drop zone ---- */
.ln-file-dropzone {
    position: fixed;
    inset: 0;
    z-index: 9100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.90);
    border: 3px dashed var(--primary-color, #667eea);
    pointer-events: none;
    transition: opacity 0.1s ease;
}

.ln-file-dropzone.ln-dropzone-active {
    display: flex;
    pointer-events: all;
}

.ln-file-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--text-primary, #111827);
    font-size: 17px;
    font-weight: 500;
    opacity: 0.80;
    pointer-events: none;
    user-select: none;
}

.ln-file-dropzone-inner svg {
    opacity: 0.65;
    color: var(--primary-color, #667eea);
}

/* Dark mode overlay */
@media (prefers-color-scheme: dark) {
    .ln-file-dropzone {
        background: rgba(17, 24, 39, 0.92);
        border-color: var(--primary-color, #667eea);
    }
}

/* ---- Persistent canvas drop strip ---- */
.ln-canvas-drop-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed;
    top: max(20px, env(safe-area-inset-top, 20px));
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: calc(var(--ln-float-control-size) + (var(--ln-float-pad) * 2));
    padding: 0 12px;
    box-sizing: border-box;
    background: #f6f7f8;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 0 0 10px 10px;
    color: #9ca3af;
    font-size: 12px;
    font-family: inherit;
    user-select: none;
    cursor: default;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    z-index: 1000;
}

@media (max-width: 768px) {
    .ln-canvas-drop-strip {
        top: max(10px, env(safe-area-inset-top, 10px));
    }
}

.ln-canvas-drop-strip:hover {
    background: #f0f1f2;
}

.ln-canvas-drop-strip:focus-visible {
    outline: 2px solid var(--primary-color, #667eea);
    outline-offset: -2px;
}

.ln-drop-strip-icon {
    flex-shrink: 0;
    color: #c4c9d1;
    transition: color 0.12s ease;
}

.ln-drop-strip-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ln-drop-strip-browse {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.85);
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.ln-drop-strip-browse-icon {
    flex-shrink: 0;
    display: block;
    pointer-events: none;
}

.ln-drop-strip-browse:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(102, 126, 234, 0.35);
    color: #7c8db5;
}

.ln-drop-strip-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Drag-over highlight state */
.ln-canvas-drop-strip.ln-drop-strip-over {
    background: color-mix(in srgb, var(--primary-color, #667eea) 6%, #f6f7f8);
    border-bottom-color: rgba(102, 126, 234, 0.28);
    color: #8b95c4;
}

.ln-canvas-drop-strip.ln-drop-strip-over .ln-drop-strip-icon {
    color: #9aa8d4;
}

.ln-canvas-drop-strip.ln-drop-strip-over .ln-drop-strip-browse {
    border-color: rgba(102, 126, 234, 0.28);
    color: #8b95c4;
}

/* Dark mode strip */
[data-theme="dark"] .ln-canvas-drop-strip {
    background: #2e3340;
    border-bottom-color: rgba(148, 163, 184, 0.12);
    color: rgba(148, 163, 184, 0.65);
}

[data-theme="dark"] .ln-canvas-drop-strip:hover {
    background: #343a48;
}

[data-theme="dark"] .ln-drop-strip-icon {
    color: rgba(148, 163, 184, 0.45);
}

[data-theme="dark"] .ln-drop-strip-browse {
    background: rgba(31, 41, 55, 0.6);
    border-color: rgba(148, 163, 184, 0.14);
    color: rgba(148, 163, 184, 0.65);
}

[data-theme="dark"] .ln-drop-strip-browse:hover {
    background: rgba(55, 65, 81, 0.7);
    border-color: rgba(102, 126, 234, 0.35);
    color: rgba(139, 158, 255, 0.85);
}

[data-theme="dark"] .ln-canvas-drop-strip.ln-drop-strip-over {
    background: rgba(102, 126, 234, 0.1);
    border-bottom-color: rgba(102, 126, 234, 0.28);
    color: rgba(139, 158, 255, 0.8);
}

[data-theme="dark"] .ln-canvas-drop-strip.ln-drop-strip-over .ln-drop-strip-icon {
    color: rgba(139, 158, 255, 0.7);
}
