/* [[Links]] between notes and "Linked from" (Phase 7f, mockup A) */
.note-link {
    color: var(--primary, #357ABD);
    border-bottom: 1px solid rgba(53, 122, 189, 0.35);
    cursor: pointer;
    white-space: nowrap;
}
.note-link::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 3px;
    vertical-align: -1px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E") center / contain no-repeat;
}
.note-link:hover { border-bottom-color: currentColor; }

.note-link-picker {
    position: fixed;
    z-index: var(--z-layer-picker);
    width: 300px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    font-size: var(--font-size-sm);
    line-height: 1.4;
}
.note-link-picker[hidden] { display: none; }
.note-link-picker-head {
    padding: 4px 10px 6px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
}
.note-link-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}
.note-link-option span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-link-option small { color: var(--text-tertiary); font-size: var(--font-size-12); white-space: nowrap; }
.note-link-option svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: var(--text-tertiary); stroke-width: 1.8; }
.note-link-option.selected,
.note-link-option:hover { background: var(--accent-blue-light, rgba(74, 144, 217, 0.12)); }
.note-link-option.new {
    margin-top: 4px;
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    color: var(--primary, #357ABD);
}
.note-link-empty { padding: 7px 10px; color: var(--text-tertiary); }

/* Linked from: right after the text, so the editor's click-space moves below it */
.note-editor:has(+ .note-backlinks:not([hidden])) {
    flex: 0 0 auto; /* the editor stretches to fill the tab otherwise, and pushes this down */
    height: auto;
    min-height: 0;
    padding-bottom: 8px;
}
.note-editor:has(+ .note-backlinks:not([hidden]))::after { height: 24px; } /* was 150px of click space */
.note-backlinks {
    margin-top: 20px;
    padding: 16px 0 200px;
    border-top: 1px solid var(--border-light);
}
.note-backlinks[hidden] { display: none; }
.note-backlinks-head {
    margin: 0 0 10px;
    font-size: var(--font-size-12);
    font-weight: 600;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
}
.note-backlink {
    margin: 0 -10px 2px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
}
.note-backlink:hover { background: var(--bg-secondary); }
.note-backlink-title { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.note-backlink-excerpt { margin-top: 2px; font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.note-backlink-excerpt b { font-weight: 500; color: var(--primary, #357ABD); }

[data-theme="dark"] .note-link-picker { box-shadow: var(--shadow-2); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .note-link-picker { box-shadow: var(--shadow-2); }
}
