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

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

.loading-spinner svg {
    width: 100%;
    height: 100%;
    color: var(--accent);
}

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

.loading-text {
    margin-top: 1rem;
    font-family: var(--font-sans);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

:root {
    --font-mono: 'IBM Plex Mono', monospace;
    --font-sans: 'IBM Plex Sans', sans-serif;
    
    /* Light theme */
    --bg-primary: #fafaf9;
    --bg-secondary: #f5f5f4;
    --bg-tertiary: #e7e5e4;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-tertiary: #a8a29e;
    --border-color: #e7e5e4;
    --accent: #c2410c;
    --accent-hover: #9a3412;
    --accent-bg: #fef3c7;
    --tag-bg: #fef3c7;
    --tag-text: #92400e;
    --date-bg: #dbeafe;
    --date-text: #1e40af;
    --link-color: #2563eb;
    --internal-link: #7c3aed;
    --highlight-bg: #fef08a;
    --code-bg: #f5f5f4;
    --quote-border: #d6d3d1;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --todo-checked: #a8a29e;
    --bullet-color: #78716c;
    --menu-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0c0a09;
        --bg-secondary: #1c1917;
        --bg-tertiary: #292524;
        --bg-hover: rgba(255, 255, 255, 0.05);
        --text-primary: #fafaf9;
        --text-secondary: #a8a29e;
        --text-tertiary: #78716c;
        --border-color: #292524;
        --accent: #fb923c;
        --accent-hover: #fdba74;
        --accent-bg: #431407;
        --tag-bg: #451a03;
        --tag-text: #fcd34d;
        --date-bg: #1e3a5f;
        --date-text: #93c5fd;
        --link-color: #60a5fa;
        --internal-link: #a78bfa;
        --highlight-bg: #854d0e;
        --code-bg: #292524;
        --quote-border: #57534e;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
        --todo-checked: #57534e;
        --bullet-color: #78716c;
        --menu-bg: #1c1917;
    }
}

html, body {
    overscroll-behavior: none;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

a, a:visited {
    color: var(--accent);
}

/* App Container */
.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Hide sidebar on smaller screens */
.doc-sidebar {
    display: none;
}

/* Sidebar layout for larger screens */
@media (min-width: 1200px) {
    .app {
        max-width: 1400px;
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: auto auto 1fr;
        gap: 0 2rem;
        padding: 0 2rem;
    }

    .header {
        grid-column: 2;
        grid-row: 1;
        /* Right-align icons when sidebar is visible */
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .breadcrumbs {
        grid-column: 2;
        grid-row: 2;
    }

    .content {
        grid-column: 2;
        grid-row: 3;
    }

    .filter-banner {
        grid-column: 2;
    }

    .doc-sidebar {
        display: block;
        grid-column: 1;
        grid-row: 1 / -1;
        position: sticky;
        top: 1rem;
        height: calc(100vh - 2rem);
        overflow-y: auto;
        padding: 1rem 2rem;
    }

    .doc-selector-container {
        display: none;
    }

    .header-actions {
        margin-left: auto;
    }

    .doc-sidebar-header {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
    }

    .doc-sidebar-list {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .doc-sidebar-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.625rem 0.75rem;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-family: var(--font-sans);
        font-size: 0.875rem;
        color: var(--text-primary);
        text-align: left;
        transition: all 0.15s ease;
        width: 100%;
    }

    .doc-sidebar-item:hover {
        background: var(--bg-hover);
    }

    .doc-sidebar-item.active {
        background: var(--accent-bg);
        color: var(--accent);
        font-weight: 500;
    }

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

    .doc-sidebar-item.active svg {
        color: var(--accent);
    }

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

    .doc-sidebar-actions {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding-top: 1rem;
        margin-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .doc-sidebar-action {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        padding: 0.625rem 0.75rem;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-family: var(--font-sans);
        font-size: 0.875rem;
        color: var(--text-secondary);
        text-align: left;
        transition: all 0.15s ease;
    }

    .doc-sidebar-action:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .doc-sidebar-action.danger {
        color: #dc2626;
    }

    .doc-sidebar-action.danger:hover {
        background: rgba(220, 38, 38, 0.1);
    }

    .doc-sidebar-action svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 100;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.doc-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.doc-selector:hover {
    background: var(--bg-hover);
}

.doc-selector-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-selector-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    transition: transform 0.15s ease;
}

.doc-selector.open .doc-selector-arrow {
    transform: rotate(180deg);
}

/* Document Dropdown */
.doc-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.25rem;
    min-width: 280px;
    max-width: 320px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.doc-dropdown.active {
    display: block;
}

.doc-dropdown-section {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.doc-dropdown-section:last-child {
    border-bottom: none;
}

.doc-dropdown-title {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem 0.25rem;
}

.doc-list {
    max-height: 240px;
    overflow-y: auto;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    text-align: left;
    transition: all 0.15s ease;
}

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

.doc-item.active {
    background: var(--bg-hover);
    color: var(--accent);
}

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

.doc-item.active svg {
    color: var(--accent);
}

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

.doc-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: left;
    transition: all 0.15s ease;
}

.doc-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.doc-action.danger {
    color: #dc2626;
}

.doc-action.danger:hover {
    background: #fef2f2;
}

@media (prefers-color-scheme: dark) {
    .doc-action.danger:hover {
        background: #450a0a;
    }
}

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

.doc-name-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.doc-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    min-height: 44px;
}

.breadcrumb {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: all 0.15s ease;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.breadcrumb-sep {
    color: var(--text-tertiary);
    user-select: none;
}

/* Search/Filter Results */
.filter-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--accent-bg);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.filter-banner.active {
    display: flex;
}

.filter-banner .filter-text {
    color: var(--accent);
    font-weight: 500;
}

.filter-banner .close-filter {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-banner .close-filter:hover {
    background: rgba(0,0,0,0.1);
}

/* Main Content */
.content {
    flex: 1;
    padding: 1rem 0 6rem;
}

/* Bullet List */
.bullet-list,
.bullet-children {
    list-style: none;
}

.bullet-item {
    position: relative;
}

.bullet-item.highlight-flash {
    animation: highlight-pulse 2s ease-out;
}

@keyframes highlight-pulse {
    0% {
        background: rgba(124, 58, 237, 0.3);
    }
    50% {
        background: rgba(124, 58, 237, 0.15);
    }
    100% {
        background: transparent;
    }
}

.bullet-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.375rem 0;
    border-radius: 6px;
    transition: background 0.1s ease;
}

.bullet-row:hover {
    background: var(--bg-hover);
}

.bullet-row.dragging {
    opacity: 0.5;
    background: var(--bg-tertiary);
}

.bullet-row.drag-over {
    border-top: 2px solid var(--accent);
}

.bullet-controls {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
    padding-top: 0.125rem;
}

.drag-handle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s ease;
    touch-action: none;
}

.bullet-row:hover .drag-handle {
    opacity: 1;
}

@media (pointer: coarse) {
    .drag-handle {
        opacity: 1;
    }
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    width: 14px;
    height: 14px;
}

.indent-btn,
.outdent-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-bg);
    border: none;
    color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-right: 2px;
}

.indent-btn:hover,
.outdent-btn:hover {
    background: var(--accent);
    color: white;
}

.indent-btn:active,
.outdent-btn:active {
    transform: scale(0.95);
}

.indent-btn svg,
.outdent-btn svg {
    width: 14px;
    height: 14px;
}

.collapse-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.collapse-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.collapse-btn svg {
    width: 12px;
    height: 12px;
    transition: transform 0.15s ease;
}

.collapse-btn.collapsed svg {
    transform: rotate(-90deg);
}

.collapse-btn.hidden {
    visibility: hidden;
}

.bullet-marker {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.bullet-marker:hover {
    transform: scale(1.2);
}

.bullet-dot {
    width: 6px;
    height: 6px;
    background: var(--bullet-color);
    border-radius: 50%;
    transition: all 0.15s ease;
}

.bullet-marker:hover .bullet-dot {
    background: var(--accent);
}

/* Todo Checkbox */
.todo-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid var(--bullet-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

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

.todo-checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.todo-checkbox.checked svg {
    color: white;
}

.todo-checkbox svg {
    width: 10px;
    height: 10px;
    color: transparent;
}

/* Bullet Content */
.bullet-content {
    flex: 1;
    min-width: 0;
}

.bullet-editor {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    padding: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bullet-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
}

.bullet-editor.checked {
    color: var(--todo-checked);
    text-decoration: line-through;
}

/* Rendered content */
.bullet-editor strong {
    font-weight: 600;
}

.bullet-editor em {
    font-style: italic;
}

.bullet-editor mark {
    background: var(--highlight-bg);
    padding: 0.1em 0.2em;
    border-radius: 2px;
}

.bullet-editor code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

.bullet-editor .quote {
    border-left: 3px solid var(--quote-border);
    padding-left: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.bullet-editor a {
    color: var(--link-color);
    text-decoration: none;
}

.bullet-editor a:hover {
    text-decoration: underline;
}

.bullet-editor .internal-link {
    color: var(--internal-link);
    cursor: pointer;
    background: rgba(124, 58, 237, 0.1);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

.bullet-editor .internal-link:hover {
    background: rgba(124, 58, 237, 0.2);
}

.bullet-editor .hashtag {
    color: var(--tag-text);
    background: var(--tag-bg);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.bullet-editor .hashtag:hover {
    filter: brightness(0.95);
}

.bullet-editor .date-tag {
    color: var(--date-text);
    background: var(--date-bg);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.bullet-editor .date-tag:hover {
    filter: brightness(0.95);
}

/* Nested children */
.bullet-children {
    margin-left: 2.25rem;
    padding-left: 0.75rem;
    position: relative;
}

.bullet-children::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0.5rem;
    width: 1px;
    background: var(--border-color);
}

.bullet-children.collapsed {
    display: none;
}

/* Command Menu */
.command-menu {
    position: fixed;
    background: var(--menu-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    max-width: 280px;
    z-index: 1000;
    overflow: hidden;
    animation: menuFadeIn 0.15s ease;
    display: none;
}

.command-menu.active {
    display: block;
}

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

.command-menu-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.command-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    transition: background 0.1s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
}

.command-item:hover,
.command-item.selected {
    background: var(--bg-hover);
}

.command-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.command-item-icon svg {
    width: 16px;
    height: 16px;
}

.command-item-text {
    flex: 1;
}

.command-item-shortcut {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* Date Picker */
.date-picker {
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

.date-picker input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.date-picker input:focus {
    outline: none;
    border-color: var(--accent);
}

.date-picker button {
    padding: 0.5rem 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.date-picker button:hover {
    background: var(--accent-hover);
}

/* Repeat Picker */
.repeat-picker {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.repeat-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.15s ease;
    text-align: left;
}

.repeat-option:hover {
    background: var(--bg-hover);
}

.repeat-option svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.repeat-option.repeat-remove {
    color: #dc2626;
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
    padding-top: 0.75rem;
}

.repeat-option.repeat-remove svg {
    color: #dc2626;
}

/* Repeat Tag */
.repeat-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.repeat-tag:hover {
    background: #bfdbfe;
}

.repeat-tag svg {
    width: 12px;
    height: 12px;
}

@media (prefers-color-scheme: dark) {
    .repeat-tag {
        background: #1e3a5f;
        color: #60a5fa;
    }
    .repeat-tag:hover {
        background: #1e4976;
    }
}

/* Link Input */
.link-input-container {
    padding: 0.75rem;
}

.link-input-container input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.link-input-container input:focus {
    outline: none;
    border-color: var(--accent);
}

.link-input-container button {
    width: 100%;
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.link-input-container button:hover {
    background: var(--accent-hover);
}

/* Internal Link Suggestions */
.internal-link-suggestions {
    max-height: 200px;
    overflow-y: auto;
}

.suggestion-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background 0.1s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Settings Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

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

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

.modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    /* border-bottom: 1px solid var(--border-color); */
}

.modal-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

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

.modal-body {
    padding: 1.25rem;
}

.task-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.task-tab {
    flex: 1;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.task-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.task-tab.active {
    background: var(--accent-bg);
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.task-content {
    max-height: 60vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.15s ease;
    margin-bottom: 0.5rem;
}

.settings-btn:last-child {
    margin-bottom: 0;
}

.settings-btn:hover {
    background: var(--bg-tertiary);
}

.settings-btn.danger {
    color: #dc2626;
    border-color: #fecaca;
}

.settings-btn.danger:hover {
    background: #fef2f2;
}

@media (prefers-color-scheme: dark) {
    .settings-btn.danger {
        border-color: #7f1d1d;
    }
    .settings-btn.danger:hover {
        background: #450a0a;
    }
}

.settings-btn svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.settings-btn.danger svg {
    color: #dc2626;
}

/* Large modal variant */
.modal-large {
    max-width: 500px;
}

/* Calendar styles */
/* Calendar View Toggle */
.calendar-view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 6px;
}

.calendar-view-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.calendar-view-btn svg {
    width: 16px;
    height: 16px;
}

.calendar-view-btn:hover {
    color: var(--text-primary);
}

.calendar-view-btn.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calendar-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.calendar-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.calendar-month-year {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

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

.calendar-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    padding: 0.5rem 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-secondary);
    position: relative;
}

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

.calendar-day.other-month {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.calendar-day.today {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-day.has-items {
    background: var(--accent);
    color: white;
    font-weight: 500;
}

.calendar-day.has-items:hover {
    background: var(--accent-hover);
}

.calendar-day.has-items.today {
    box-shadow: inset 0 0 0 2px var(--text-primary);
}

.calendar-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: color 0.15s ease;
}

.calendar-back-btn:hover {
    color: var(--text-primary);
}

.calendar-back-btn svg {
    width: 16px;
    height: 16px;
}

.calendar-day-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.calendar-day-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.calendar-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.calendar-item:hover {
    border-color: var(--accent);
}

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

/* Calendar List View */
.calendar-list-view {
    max-height: 60vh;
    overflow-y: auto;
}

.calendar-list-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.calendar-list-date-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calendar-list-date-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.calendar-list-date-subtext {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 0.5rem;
}

.calendar-list-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calendar-list-empty {
    padding: 3rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* Search Results */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.search-result-item:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

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

.search-result-match {
    background: var(--highlight-bg);
    padding: 0 0.125rem;
    border-radius: 2px;
    font-weight: 500;
}

.search-result-path {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

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

.calendar-item-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.calendar-item-text {
    flex: 1;
}

.calendar-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-tertiary);
}

/* Filter results view */
.filter-results {
    padding: 1rem;
}

.filter-results-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* File input hidden */
.hidden-input {
    display: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state-text {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.empty-state-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.2s ease;
}

.toast.out {
    animation: toastOut 0.2s ease forwards;
}

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

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

/* Mobile Responsive */
@media (max-width: 640px) {
    .header {
        padding: 0.75rem 0;
    }

    .breadcrumbs {
        padding: 0.5rem 0;
        font-size: 0.8125rem;
    }

    .breadcrumb {
        max-width: 100px;
    }

    .bullet-children {
        margin-left: 1rem;
    }

    .bullet-editor {
        font-size: 1rem;
    }

    .command-menu {
        left: 1rem !important;
        right: 1rem !important;
        min-width: auto;
        max-width: none;
    }
}

/* Selection highlight */
::selection {
    background: var(--accent);
    color: white;
}

/* Multi-selection highlight */
.bullet-item.multi-selected > .bullet-row {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: 4px;
}

.bullet-item.multi-selected > .bullet-row .bullet-editor {
    caret-color: transparent;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Keyboard shortcuts help */
.keyboard-hint {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    display: none;
}

@media (min-width: 768px) {
    .keyboard-hint {
        display: block;
    }
}

/* Sync & Account Styles */
.sync-info {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sync-info-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--accent);
}

.sync-error {
    padding: 0.75rem;
    background: #fef2f2;
    color: #991b1b;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

@media (prefers-color-scheme: dark) {
    .sync-error {
        background: #450a0a;
        color: #fca5a5;
    }
}

.sync-status {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.sync-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.sync-status-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.sync-status-value {
    color: var(--text-primary);
    font-weight: 600;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.session-item.current {
    background: var(--accent-bg);
    border-color: var(--accent);
}

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

.session-device {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

.session-actions {
    display: flex;
    gap: 0.5rem;
}

.session-badge {
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.session-delete {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

@media (prefers-color-scheme: dark) {
    .session-delete:hover {
        background: #450a0a;
    }
}

.session-delete svg {
    width: 16px;
    height: 16px;
}

/* Cloud icon states */
#syncBtn {
    position: relative;
}

#syncBtn.syncing {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Floating Edit Toggle Button */
.floating-edit-toggle {
    display: flex;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
}

.floating-edit-toggle:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.floating-edit-toggle:active {
    transform: scale(0.95);
}

.floating-edit-toggle svg {
    width: 24px;
    height: 24px;
}

.floating-edit-toggle.editing-disabled {
    background: var(--text-tertiary);
}

.floating-edit-toggle.editing-disabled:hover {
    background: var(--text-secondary);
}

.floating-edit-toggle.editing-disabled .edit-icon {
    display: none;
}

.floating-edit-toggle.editing-disabled .edit-icon-disabled {
    display: block;
}

/* Offline Banner */
.offline-banner {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    color: #92400e;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
}

.offline-banner.update-banner {
    background: #dbeafe;
    color: #1e40af;
}

.offline-banner .reload-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.offline-banner .reload-btn:hover {
    background: var(--accent-hover);
}

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