/* ====================================================================
 * Notes module — full styling (sidebar / editor / right rail / markdown).
 * Tokens live on #page-notes so they don't bleed into other pages.
 * ==================================================================== */

#page-notes {
    --bg-0: #0a0d12;
    --bg-1: #0f131a;
    --surface: #161b22;
    --surface-alt: #1e2228;
    --surface-elev: #232932;
    --border: #2a313b;
    --border-strong: #3a4250;

    --text-primary: #e8edf3;
    --text-secondary: #8a95a5;
    --text-muted: #5a6472;

    --accent: #4fc3f7;
    --accent-hot: #2bb0e8;
    --good: #4ade80;
    --warn: #fbbf24;
    --bad:  #f87171;

    --race-t: #4a90d9;
    --race-p: #f4c542;
    --race-z: #b366f0;

    --font-display: 'Rajdhani', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    background: var(--bg-0);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
}

#page-notes.active {
    display: flex !important;
    flex-direction: column;
    /* Fill the viewport below the top nav. The app uses block layout on
       .app-main, so .page elements default to content-height — Notes
       needs to claim the whole window. */
    height: calc(100vh - 50px);
}

/* Container fills the viewport below the topbar */
#page-notes .notes-shell {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ================================================================
 * SIDEBAR
 * ================================================================ */

.notes-sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ns-head {
    padding: 14px 16px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ns-title {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.ns-new-btn {
    width: 24px; height: 24px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--bg-0);
    border: 0;
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ns-new-btn:hover { background: var(--accent-hot); }

.ns-search {
    padding: 0 12px 10px;
    flex-shrink: 0;
}
.ns-search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 12px;
}
.ns-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.ns-quicklinks {
    padding: 0 8px 10px;
    flex-shrink: 0;
}
.ns-link {
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.ns-link:hover {
    background: var(--surface);
    color: var(--text-primary);
}
.ns-link-icon { font-size: 13px; }
.ns-link-label { flex: 1; }
.ns-link-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.ns-section-label {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 8px 16px 4px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.ns-folder-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 10px;
}

.ns-folder, .ns-note {
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background 0.08s;
}
.ns-folder {
    color: var(--text-secondary);
    font-weight: 500;
}
.ns-folder:hover { background: var(--surface); }
.ns-folder-chev {
    color: var(--text-muted);
    font-size: 10px;
    width: 12px;
    text-align: center;
}
.ns-folder-icon { font-size: 12px; }
.ns-folder-name { flex: 1; }
.ns-folder-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.ns-note {
    color: var(--text-secondary);
    border-left: 2px solid transparent;
}
.ns-note:hover {
    background: var(--surface);
    color: var(--text-primary);
}
.ns-note.active {
    background: var(--surface);
    color: var(--text-primary);
    border-left-color: var(--accent);
}
.ns-note-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ns-note-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ns-note-pin {
    color: var(--warn);
    font-size: 10px;
}

.ns-tags {
    padding: 4px 12px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex-shrink: 0;
}
.ns-tag-chip {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.ns-tag-chip:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}
.ns-tag-chip.active {
    background: var(--accent);
    color: var(--bg-0);
    border-color: var(--accent);
}
.ns-tag-count { color: var(--text-muted); margin-left: 3px; }

/* ================================================================
 * MAIN (editor area)
 * ================================================================ */

.notes-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-0);
}
.notes-tabs {
    display: none; /* Phase 1: single-note focus, no tab bar yet */
}
.notes-editor {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

/* Empty / loading / error states */
.ed-empty, .ed-loading, .ed-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}
.ed-empty-glyph { font-size: 36px; opacity: 0.6; margin-bottom: 12px; }
.ed-empty-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.ed-empty-body { color: var(--text-secondary); font-size: 13px; margin-bottom: 18px; max-width: 320px; }
.ed-empty-new {
    padding: 10px 18px;
    background: var(--accent);
    color: var(--bg-0);
    border: 0;
    border-radius: 4px;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    cursor: pointer;
}
.ed-empty-new:hover { background: var(--accent-hot); }

.ed-loading { padding: 40px; align-items: stretch; }
.ed-error-icon { font-size: 28px; color: var(--bad); margin-bottom: 8px; }
.ed-error-title {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--bad);
    font-size: 16px;
    margin-bottom: 6px;
}
.ed-error-body { color: var(--text-secondary); font-size: 13px; }

/* Document */
.ed-doc {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.ed-header {
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.ed-breadcrumb {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.ed-bc-sep { margin: 0 4px; }
.ed-title {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.01em;
}
.ed-title:focus {
    outline: none;
    background: var(--surface);
}
.ed-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ed-status {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    min-width: 56px;
    text-align: right;
}
.ed-status-err { color: var(--bad); }
.ed-action {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.ed-action:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.ed-pin.on {
    color: var(--warn);
    border-color: var(--warn);
}

.ed-frontmatter {
    margin: 16px 28px 0;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
}
.fm-row {
    display: flex;
    gap: 10px;
    padding: 2px 0;
}
.fm-key {
    color: var(--text-muted);
    width: 100px;
    flex-shrink: 0;
}
.fm-val { color: var(--text-primary); }
.fm-good { color: var(--good); }
.fm-bad  { color: var(--bad); }

/* Two-pane editor */
.ed-panes {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 0;
    margin: 16px 28px 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.ed-source-pane {
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
}
.ed-source {
    flex: 1;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    padding: 18px 20px;
    resize: none;
    outline: none;
    tab-size: 2;
    overflow: auto;
}
.ed-source::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.ed-preview {
    overflow: auto;
    padding: 18px 24px 32px;
    background: var(--bg-0);
    line-height: 1.6;
    font-size: 14px;
    color: var(--text-primary);
}

/* ================================================================
 * RIGHT RAIL
 * ================================================================ */

.notes-rail {
    width: 280px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    background: var(--bg-1);
    overflow-y: auto;
}
.nr-section {
    border-bottom: 1px solid var(--border);
}
.nr-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
}
.nr-icon { font-size: 12px; color: var(--text-muted); }
.nr-title {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-secondary);
    text-transform: uppercase;
    flex: 1;
}
.nr-count {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
    padding: 1px 6px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 8px;
}
.nr-body { padding-bottom: 10px; }
.nr-empty {
    padding: 10px 14px;
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}
.nr-item {
    padding: 8px 14px;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background 0.1s;
}
.nr-item:hover { background: var(--surface); }
.nr-item-unlinked { border-left-color: var(--warn); }
.nr-item-title {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 3px;
}
.nr-item-excerpt {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.nr-outline-item {
    padding: 4px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.1s;
}
.nr-outline-item:hover { color: var(--text-primary); }
.nr-outline-l1 { font-weight: 500; color: var(--text-primary); }
.nr-outline-l2 { padding-left: 24px; }
.nr-outline-l3 { padding-left: 34px; }
.nr-outline-l4 { padding-left: 44px; }

/* ================================================================
 * SIGNED-OUT
 * ================================================================ */

.notes-signed-out {
    max-width: 720px;
    margin: 60px auto;
    padding: 36px 32px;
    background: linear-gradient(180deg, var(--surface-alt), var(--surface));
    border: 1px solid var(--border);
    border-radius: 14px;
    text-align: center;
}
.notes-signed-out-badge { font-size: 38px; margin-bottom: 8px; }
.notes-signed-out-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary);
}
.notes-signed-out-body {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    max-width: 560px;
    margin: 0 auto 22px;
}
.notes-signed-out-features {
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    text-align: left;
}
.notes-signed-out-features li {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.notes-feat-icon { font-size: 20px; }
.notes-signed-out-features b {
    color: var(--text-primary);
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 2px;
}
.notes-signed-out-features code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    background: rgba(79, 195, 247, 0.08);
    padding: 1px 4px;
    border-radius: 2px;
}
.notes-signed-out-cta {
    color: var(--text-secondary);
    font-size: 13px;
}
.notes-signed-out-cta b { color: var(--accent); }

/* ================================================================
 * MARKDOWN PREVIEW STYLING
 * ================================================================ */

.ed-preview h1, .ed-preview h2, .ed-preview h3, .ed-preview h4 {
    font-family: var(--font-display);
    color: var(--text-primary);
    margin: 1.2em 0 0.5em;
    line-height: 1.2;
}
.ed-preview h1 { font-size: 26px; font-weight: 700; }
.ed-preview h2 {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-top: 1.6em;
}
.ed-preview h3 { font-size: 14px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-primary); }
.ed-preview h4 { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }

.ed-preview p { margin: 0.7em 0; font-size: 14px; color: var(--text-primary); }
.ed-preview ul, .ed-preview ol { padding-left: 22px; margin: 0.5em 0; }
.ed-preview li { margin: 4px 0; font-size: 14px; line-height: 1.6; }

.ed-preview a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(79, 195, 247, 0.4);
}
.ed-preview a:hover { text-decoration-color: var(--accent); }

.ed-preview a.wikilink {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
    padding: 0 1px;
    cursor: pointer;
}
.ed-preview a.wikilink:hover { background: rgba(79, 195, 247, 0.06); }
.ed-preview a.wikilink.wikilink-red {
    color: var(--bad);
    border-bottom-color: var(--bad);
    border-bottom-style: dotted;
}
.ed-preview .wikilink-block {
    color: var(--text-muted);
    margin-left: 2px;
    font-family: var(--font-mono);
    font-size: 12px;
}
.ed-preview .wikilink-transclude {
    margin: 10px 0;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-style: italic;
    color: var(--text-secondary);
}

.ed-preview .tag {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 1px 6px;
    background: rgba(79, 195, 247, 0.08);
    color: var(--accent);
    border-radius: 2px;
    margin: 0 1px;
    cursor: pointer;
}

.ed-preview blockquote {
    margin: 14px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: rgba(79, 195, 247, 0.06);
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.6;
}
.ed-preview blockquote.callout-loss { border-left-color: var(--bad); background: rgba(248, 113, 113, 0.07); }
.ed-preview blockquote.callout-win  { border-left-color: var(--good); background: rgba(74, 222, 128, 0.07); }
.ed-preview blockquote.callout-warn { border-left-color: var(--warn); background: rgba(251, 191, 36, 0.06); }
.ed-preview blockquote.callout-tip  { border-left-color: var(--accent); background: rgba(79, 195, 247, 0.06); }
.ed-preview blockquote.callout-coach { border-left-color: var(--race-z); background: rgba(179, 102, 240, 0.07); }
.ed-preview blockquote.callout-info { border-left-color: var(--accent); }

.ed-preview code {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 1px 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--accent);
}
.ed-preview pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 12px 0;
}
.ed-preview pre code {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--text-primary);
    font-size: 12.5px;
}

.ed-preview hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.ed-preview table {
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
    width: 100%;
}
.ed-preview th, .ed-preview td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.ed-preview th {
    font-family: var(--font-display);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.ed-preview img { max-width: 100%; border-radius: 4px; }

/* Build-order block */
.ed-preview .build-block {
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    font-size: 12px;
}
.ed-preview .build-head {
    padding: 6px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.ed-preview .build-grid { background: var(--bg-0); }
.ed-preview .build-row {
    display: grid;
    grid-template-columns: 64px 50px 1fr 1.4fr;
    padding: 6px 12px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.ed-preview .build-row:first-child { border-top: 0; }
.ed-preview .build-head-row {
    background: var(--surface-alt);
    font-family: var(--font-display);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    font-weight: 700;
}
.ed-preview .build-row-mistake {
    background: rgba(248, 113, 113, 0.06);
    color: var(--bad);
}
.ed-preview .build-row-mistake .build-time { color: var(--bad); }
.ed-preview .build-time { color: var(--accent); }
.ed-preview .build-sup  { color: var(--text-secondary); }
.ed-preview .build-note {
    font-family: var(--font-body);
    color: var(--text-muted);
    font-size: 12px;
}

/* Replay-frame embed */
.ed-preview .replay-embed {
    margin: 16px 0;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.ed-preview .replay-embed-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
.ed-preview .replay-embed-icon { color: var(--accent); }
.ed-preview .replay-embed-id { color: var(--text-primary); font-weight: 500; }
.ed-preview .replay-embed-sep { color: var(--text-muted); }
.ed-preview .replay-embed-stamp { color: var(--accent); }
.ed-preview .replay-embed-jump {
    margin-left: auto;
    padding: 2px 7px;
    background: var(--bg-0);
    color: var(--text-secondary);
    border-radius: 2px;
    font-size: 10px;
    cursor: pointer;
}
.ed-preview .replay-embed-jump:hover { color: var(--accent); }
.ed-preview .replay-embed-caption {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Task list checkboxes (markdown-it task lists in v14) */
.ed-preview .task-list-item { list-style: none; margin-left: -20px; }
.ed-preview input[type="checkbox"] { margin-right: 6px; }

/* ================================================================
 * SIDEBAR — view quick-links (Graph / Matrix / Canvas)
 * ================================================================ */

#page-notes .ns-link-sep {
    height: 1px;
    background: var(--border);
    margin: 8px 4px;
}
#page-notes .ns-link.active {
    background: var(--surface);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
    padding-left: 8px;
}
#page-notes .ns-link-view .ns-link-icon { color: var(--accent); }

/* Saved tag filters in the sidebar — same row chrome as quick links
 * but with a subtler accent color so the eye groups them as a separate
 * cluster ("currently learning / tracking" repertoire-style filters). */
#page-notes .ns-link-saved .ns-link-icon {
    color: var(--warn);
    font-family: var(--font-display);
    font-weight: 700;
    width: 16px;
    text-align: center;
}
#page-notes .ns-link-saved.active .ns-link-icon { color: var(--accent); }

/* ================================================================
 * VIEW HOST — graph/matrix/canvas mount
 * ================================================================ */

#page-notes .notes-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
#page-notes .notes-view-host {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#page-notes .notes-view-host > * { flex: 1; min-height: 0; }

#page-notes .notes-coming-soon {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    background: var(--bg-0);
    color: var(--text-secondary);
}
#page-notes .notes-coming-soon-glyph {
    font-size: 48px;
    color: var(--accent);
    opacity: 0.5;
}
#page-notes .notes-coming-soon-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}
#page-notes .notes-coming-soon-body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary);
    max-width: 460px;
    text-align: center;
}
#page-notes .notes-coming-soon-actions {
    margin-top: 12px;
    display: flex;
    gap: 12px;
}
#page-notes .ncs-link {
    padding: 7px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
#page-notes .ncs-link:hover {
    background: var(--surface-alt);
    border-color: var(--border-strong);
}

/* ================================================================
 * MATRIX VIEW
 * ================================================================ */

#page-notes .nm-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-0);
}
#page-notes .nm-header {
    height: 56px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
#page-notes .nm-header-icon {
    color: var(--accent);
    font-size: 18px;
}
#page-notes .nm-header-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text-primary);
    text-transform: uppercase;
}
#page-notes .nm-header-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
#page-notes .nm-header-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
#page-notes .nm-body {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: var(--bg-0);
}

#page-notes .nm-loading {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 60px 20px;
}

#page-notes .nm-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
#page-notes .nm-grid-row {
    display: grid;
    grid-template-columns: 180px repeat(3, 1fr);
    gap: 12px;
}
#page-notes .nm-corner { /* empty top-left */ }
#page-notes .nm-row-head {
    padding: 12px 14px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-right: 2px solid var(--accent);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#page-notes .nm-row-head-label {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-primary);
}
#page-notes .nm-row-head-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

#page-notes .nm-mu-head {
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 4px;
}
#page-notes .nm-mu-head-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
#page-notes .nm-mu-label {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
#page-notes .nm-mu-needswork {
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--bad);
    text-transform: uppercase;
    padding: 2px 6px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.33);
    border-radius: 2px;
}
#page-notes .nm-mu-record {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
#page-notes .nm-mu-bar {
    margin-top: 8px;
    height: 4px;
    background: var(--bg-0);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}
#page-notes .nm-mu-bar-fill {
    height: 100%;
    background: var(--good);
    border-radius: 2px;
    transition: width 0.3s ease;
}
#page-notes .nm-mu-bar-fill.hot { background: var(--bad); }
#page-notes .nm-mu-bar-foot {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

#page-notes .nm-cell {
    padding: 10px;
    min-height: 130px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#page-notes .nm-cell.hot {
    background: rgba(248, 113, 113, 0.04);
    border-color: rgba(248, 113, 113, 0.27);
}
#page-notes .nm-pill {
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}
#page-notes .nm-pill:hover {
    background: var(--surface-alt);
    border-color: var(--border-strong);
}
#page-notes .nm-pill.hot { border-left: 2px solid var(--bad); }
#page-notes .nm-pill.mistake { border-left: 2px solid var(--warn); }
#page-notes .nm-pill-title {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}
#page-notes .nm-pill-pin {
    color: var(--warn);
    margin-right: 4px;
}
#page-notes .nm-pill-meta {
    margin-top: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
#page-notes .nm-pill-tag {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--accent);
    padding: 1px 4px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 2px;
}
#page-notes .nm-pill-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-left: auto;
}
#page-notes .nm-cell-foot {
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}
#page-notes .nm-cell-count { flex: 1; }
#page-notes .nm-cell-newbtn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 0;
}
#page-notes .nm-cell-newbtn:hover { text-decoration: underline; }
#page-notes .nm-cell-newbtn-empty {
    flex: 1;
    align-self: stretch;
    border: 1px dashed var(--border);
    border-radius: 3px;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-body);
    font-size: 11px;
    text-align: center;
    padding: 8px;
}
#page-notes .nm-cell-newbtn-empty:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#page-notes .nm-placeholder-note {
    margin-top: 18px;
    padding: 12px 14px;
    background: rgba(251, 191, 36, 0.05);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-left: 3px solid var(--warn);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

/* ================================================================
 * COMMAND PALETTE (Cmd/Ctrl + K)
 * ================================================================ */

.np-palette {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
}
.np-palette-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 13, 18, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.np-palette-card {
    position: relative;
    width: 560px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 200px);
    background: #232932;
    border: 1px solid #3a4250;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
}
.np-palette-input-row {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2a313b;
    flex-shrink: 0;
}
.np-palette-icon { color: #4fc3f7; font-size: 16px; }
.np-palette-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 16px;
    color: #e8edf3;
}
.np-palette-input::placeholder { color: #5a6472; }
.np-palette-key {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    padding: 2px 6px;
    background: #0a0d12;
    border: 1px solid #2a313b;
    border-radius: 3px;
    color: #5a6472;
}
.np-palette-results {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    min-height: 60px;
}
.np-palette-section-title {
    padding: 8px 18px 4px;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #5a6472;
    text-transform: uppercase;
}

/* ================================================================
 * Notes Phase 2 — replay-stamp overlay
 * The overlay is mounted at document.body so it floats above the
 * replay viewer regardless of z-stacking inside #page-replay. We
 * scope tokens locally instead of inheriting from #page-notes.
 * ================================================================ */

.rs-stamp-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 13, 18, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 80px 32px 0 0;

    --rs-bg-0: #0a0d12;
    --rs-bg-1: #0f131a;
    --rs-surface: #161b22;
    --rs-surface-alt: #1e2228;
    --rs-border: #2a313b;
    --rs-border-strong: #3a4250;
    --rs-text: #e8edf3;
    --rs-text-sec: #8a95a5;
    --rs-text-muted: #5a6472;
    --rs-accent: #4fc3f7;
    --rs-bad: #f87171;
}

.rs-stamp-overlay {
    width: 420px;
    max-width: 92vw;
    background: rgba(22, 27, 34, 0.97);
    border: 1px solid var(--rs-border-strong);
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
    color: var(--rs-text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    overflow: hidden;
    animation: rs-stamp-pop 130ms ease-out;
}

@keyframes rs-stamp-pop {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.rs-stamp-head {
    padding: 10px 14px;
    background: var(--rs-bg-1);
    border-bottom: 1px solid var(--rs-border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.rs-stamp-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--rs-bad);
    animation: rs-pulse 1.5s infinite;
}
@keyframes rs-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.rs-stamp-label {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--rs-text);
}
.rs-stamp-time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--rs-accent);
}
.rs-stamp-sub {
    font-size: 11px;
    color: var(--rs-text-muted);
}
.rs-stamp-x {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--rs-border);
    color: var(--rs-text-sec);
    width: 24px; height: 24px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.rs-stamp-x:hover { color: var(--rs-text); border-color: var(--rs-border-strong); }

.rs-stamp-context {
    padding: 8px 14px;
    background: var(--rs-surface);
    border-bottom: 1px solid var(--rs-border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--rs-text-sec);
}
.rs-stamp-pill {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    padding: 2px 6px;
    background: var(--rs-bg-0);
    border-radius: 2px;
    color: var(--rs-text-sec);
}
.rs-stamp-replay-id { color: var(--rs-accent); }

.rs-stamp-thumb-wrap {
    padding: 10px 14px 4px;
    background: var(--rs-bg-0);
}
.rs-stamp-thumb {
    width: 100%;
    border: 1px solid var(--rs-border);
    border-radius: 3px;
    display: block;
}

.rs-stamp-title-wrap { padding: 12px 14px 4px; }
.rs-stamp-title {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--rs-text);
    padding: 0;
}
.rs-stamp-title::placeholder { color: var(--rs-text-muted); font-weight: 500; }

.rs-stamp-body-wrap { padding: 4px 14px 12px; }
.rs-stamp-body {
    width: 100%;
    background: var(--rs-bg-0);
    border: 1px solid var(--rs-border);
    border-radius: 4px;
    color: var(--rs-text);
    font: inherit;
    padding: 10px 12px;
    resize: vertical;
    min-height: 80px;
}
.rs-stamp-body:focus {
    outline: none;
    border-color: var(--rs-accent);
}

.rs-stamp-chips {
    padding: 0 14px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.rs-stamp-chip {
    padding: 4px 10px;
    border-radius: 3px;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--rs-surface);
    color: var(--rs-text-sec);
    border: 1px solid var(--rs-border);
    cursor: pointer;
    user-select: none;
}
.rs-stamp-chip:hover { color: var(--rs-text); }
.rs-stamp-chip.on {
    background: rgba(79, 195, 247, 0.1);
    color: var(--rs-accent);
    border-color: var(--rs-accent);
}

.rs-stamp-foot {
    padding: 10px 14px;
    background: var(--rs-bg-1);
    border-top: 1px solid var(--rs-border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.rs-stamp-status {
    font-size: 11px;
    color: var(--rs-text-muted);
}
.rs-stamp-status.rs-stamp-err { color: var(--rs-bad); }
.rs-stamp-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.rs-stamp-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--rs-surface);
    color: var(--rs-text);
    border: 1px solid var(--rs-border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.rs-stamp-btn:hover {
    border-color: var(--rs-border-strong);
    background: var(--rs-surface-alt);
}
.rs-stamp-btn-primary {
    background: var(--rs-accent);
    color: var(--rs-bg-0);
    border: none;
}
.rs-stamp-btn-primary:hover {
    background: #6dd0fa;
}
.rs-stamp-kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9px;
    padding: 1px 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    color: rgba(10, 13, 18, 0.7);
}
.rs-stamp-btn:not(.rs-stamp-btn-primary) .rs-stamp-kbd {
    background: var(--rs-bg-0);
    color: var(--rs-text-muted);
}

/* ================================================================
 * Notes Phase 2 — stamps timeline pins on the replay slider
 * Mounted as a sibling of #replay-slider inside .replay-timeline.
 * ================================================================ */

#page-replay .replay-timeline { position: relative; }
.replay-stamps-layer {
    position: absolute;
    left: 0; right: 0; top: 0; bottom: 0;
    pointer-events: none;
    z-index: 4;
}
.replay-stamp-pin {
    position: absolute;
    top: -4px;
    transform: translateX(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid #0a0d12;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    pointer-events: auto;
    padding: 0;
}
.replay-stamp-pin:hover {
    width: 13px; height: 13px;
    top: -6px;
    box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.25);
}

/* ================================================================
 * Notes Phase 2 — daily-note view (light wrapper around the editor)
 * ================================================================ */

#page-notes .ed-doc[data-note-type="daily"] .ed-header {
    border-bottom-color: var(--accent);
}

/* ================================================================
 * Notes Phase 2 — dashboard widget
 * Lives inside the dashboard, NOT #page-notes — so token lookup
 * uses the dashboard's variables directly. The card chrome (.dash-card)
 * comes from dashboard.css; we only style the inner grid here.
 * ================================================================ */

.dash-notes-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}
.dash-notes-card .dash-notes-link {
    margin-left: auto;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: #4fc3f7;
    text-decoration: none;
}
.dash-notes-card .dash-notes-link:hover { color: #6dd0fa; }

.dash-notes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 14px;
    align-items: stretch;
}
.dash-notes-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.dash-notes-section-label {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #5a6472;
    text-transform: uppercase;
}
.np-palette-row {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-left: 2px solid transparent;
    user-select: none;
}
.np-palette-row.sel {
    background: #1e2228;
    border-left-color: #4fc3f7;
}
.np-palette-row-icon {
    color: #8a95a5;
    font-size: 13px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.np-palette-row.sel .np-palette-row-icon { color: #4fc3f7; }
.np-palette-row-label {
    flex: 1;
    font-size: 13px;
    color: #e8edf3;
}

.dash-notes-daily-tile,
.dash-notes-daily-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #161b22;
    border: 1px solid #2a313b;
    border-left: 3px solid #4fc3f7;
    border-radius: 4px;
    text-decoration: none;
    color: #e8edf3;
    flex: 1;
}
.dash-notes-daily-tile:hover,
.dash-notes-daily-cta:hover {
    border-color: #4fc3f7;
    background: #1e2228;
}
.dash-notes-daily-title,
.dash-notes-daily-cta-title {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.dash-notes-daily-sub,
.dash-notes-daily-cta-sub {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #8a95a5;
    margin-top: 4px;
}
.dash-notes-daily-cta-glyph {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 28px;
    color: #4fc3f7;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(79, 195, 247, 0.08);
    flex-shrink: 0;
}

.dash-notes-pinned-list,
.dash-notes-insights-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.dash-notes-pinned-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #161b22;
    border: 1px solid #2a313b;
    border-radius: 3px;
    text-decoration: none;
    color: #e8edf3;
    font-size: 12px;
}
.dash-notes-pinned-list a:hover {
    border-color: #3a4250;
    background: #1e2228;
}
.dash-notes-pin-glyph { color: #fbbf24; }
.dash-notes-pin-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.np-palette-row-hint {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
    flex-shrink: 0;
}
.np-palette-empty {
    padding: 28px 18px;
    text-align: center;
    color: #5a6472;
    font-size: 12px;
}
.np-palette-foot {
    padding: 8px 14px;
    border-top: 1px solid #2a313b;
    background: #0f131a;
    display: flex;
    gap: 12px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
    flex-shrink: 0;
}
.np-palette-count { margin-left: auto; }
.dash-notes-pin-time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
}
.dash-notes-empty {
    font-size: 12px;
    color: #5a6472;
    padding: 12px;
    background: #161b22;
    border: 1px dashed #2a313b;
    border-radius: 3px;
    line-height: 1.5;
    flex: 1;
}
.dash-notes-insights-list li {
    padding: 10px;
    background: #161b22;
    border: 1px solid #2a313b;
    border-top: 2px solid #4fc3f7;
    border-radius: 3px;
}
.dash-notes-insight-title {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #e8edf3;
    margin-bottom: 4px;
}
.dash-notes-insight-body {
    font-size: 11px;
    line-height: 1.5;
    color: #8a95a5;
}

/* ================================================================
 * RESPONSIVE
 * ================================================================ */

@media (max-width: 1100px) {
    .notes-rail { display: none; }
    .dash-notes-grid { grid-template-columns: 1fr 1fr; }
    .dash-notes-col-insights { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
    .notes-sidebar { width: 220px; }
    .ed-panes { grid-template-columns: 1fr; }
    .ed-source-pane { border-right: 0; border-bottom: 1px solid var(--border); min-height: 200px; }
    #page-notes .nm-grid-row { grid-template-columns: 130px 1fr 1fr 1fr; }
    .np-palette-card { width: calc(100vw - 32px); }
    .dash-notes-grid { grid-template-columns: 1fr; }
}

/* ================================================================
 * PHASE 5 — Slash menu, transclusion, settings, import/export
 * ================================================================ */

/* ----- Slash menu popup --------------------------------------- */

.slash-menu {
    /* Lives at document.body level so it isn't clipped by parent overflow.
       Inherits font from #page-notes when shown, or falls back. */
    width: 280px;
    max-height: 360px;
    overflow-y: auto;
    background: #232932;
    border: 1px solid #3a4250;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    padding: 6px;
    font-size: 12px;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
}
.slash-menu .slash-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
}
.slash-menu .slash-opt:hover {
    background: #1e2228;
}
.slash-menu .slash-opt.active {
    background: #161b22;
    border-color: #4fc3f7;
}
.slash-menu .slash-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    color: #4fc3f7;
    background: rgba(79, 195, 247, .08);
    border-radius: 3px;
}
.slash-menu .slash-text { flex: 1; min-width: 0; }
.slash-menu .slash-label {
    font-size: 12px;
    color: #e8edf3;
    line-height: 1.2;
}
.slash-menu .slash-hint {
    font-size: 10px;
    color: #8a95a5;
    line-height: 1.2;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.slash-menu .slash-empty {
    padding: 16px;
    text-align: center;
    color: #5a6472;
    font-size: 12px;
}
.slash-menu .slash-foot {
    margin-top: 4px;
    padding: 4px 8px;
    border-top: 1px solid #2a313b;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
}

/* ----- Transclusion blocks ------------------------------------ */

#page-notes .ed-preview .wikilink-transclude {
    margin: 14px 0;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    background: var(--surface);
    overflow: hidden;
}
#page-notes .ed-preview .wikilink-transclude[data-state="missing"],
#page-notes .ed-preview .wikilink-transclude[data-state="no-section"] {
    border-left-color: var(--bad);
    opacity: .85;
}
#page-notes .ed-preview .transclude-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .015);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
#page-notes .ed-preview .transclude-icon {
    color: var(--accent);
    font-weight: 700;
}
#page-notes .ed-preview .transclude-target {
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    flex: 1;
}

/* ====================================================================
 * PHASE 6 — three modes / kebab menu / version history / SRS / popover
 * ==================================================================== */

/* ─── Mode chip toggle in editor header ─── */
#page-notes .ed-mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-right: 8px;
}
#page-notes .ed-mode-btn {
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}
#page-notes .ed-mode-btn:hover { color: var(--text-primary); }
#page-notes .ed-mode-btn.on {
    background: var(--accent);
    color: #06121a;
}

/* Mode-driven layout overrides.
   Live (default) = preview-only with click-to-edit affordance via Source.
   Source = textarea-only (raw markdown).
   Read   = preview-only, no edit affordances. */
#page-notes .ed-mode-live .ed-source-pane { display: none; }
#page-notes .ed-mode-live .ed-preview { width: 100%; padding: 24px 36px; }
#page-notes .ed-mode-live .ed-panes { grid-template-columns: 1fr; border: 0; }

#page-notes .ed-mode-source .ed-source-pane { width: 100%; border-right: 0; }
#page-notes .ed-mode-source .ed-preview { display: none; }
#page-notes .ed-mode-source .ed-panes { grid-template-columns: 1fr; }
#page-notes .ed-mode-source .ed-source { font-family: var(--font-mono); font-size: 13px; }

#page-notes .ed-mode-read .ed-source-pane { display: none; }
#page-notes .ed-mode-read .ed-preview { width: 100%; padding: 24px 36px; }
#page-notes .ed-mode-read .ed-panes { grid-template-columns: 1fr; border: 0; }


/* ─── Kebab menu ─── */
#page-notes .ed-kebab { font-size: 18px; padding-bottom: 4px; }
.ed-kebab-menu {
    z-index: 20000;
    background: #161b22;
    border: 1px solid #2a313b;
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    padding: 4px;
    min-width: 200px;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
}
.ed-kebab-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: #e8edf3;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
}
.ed-kebab-item:hover:not([disabled]) { background: #1e2228; }
.ed-kebab-item[disabled] { color: #5a6472; cursor: default; }


/* ─── Version history modal ─── */
.ed-history-backdrop {
    position: fixed; inset: 0;
    background: rgba(2, 6, 12, 0.78);
    z-index: 19000;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
    color: #e8edf3;
}
.ed-history-modal {
    width: min(960px, 92vw);
    height: min(640px, 88vh);
    background: #0f131a;
    border: 1px solid #2a313b;
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
}
.ed-history-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #2a313b;
    background: #0a0d12;
}
.ed-history-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 13px;
    color: #4fc3f7;
}
.ed-history-close {
    background: transparent;
    border: 0;
    color: #8a95a5;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.ed-history-close:hover { color: #e8edf3; }
.ed-history-body {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 0;
}
.ed-history-list {
    border-right: 1px solid #2a313b;
    overflow-y: auto;
    background: #0a0d12;
}
.ed-history-row {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #1e2228;
    color: #e8edf3;
    padding: 10px 12px;
    cursor: pointer;
    font-family: inherit;
}
.ed-history-row:hover { background: #161b22; }
.ed-history-row.on {
    background: #1e2228;
    box-shadow: inset 3px 0 0 #4fc3f7;
}
.ed-history-row-time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: #8a95a5;
}
.ed-history-row-meta {
    display: flex; align-items: center; gap: 6px;
    margin-top: 4px;
    font-size: 12px;
}
.ed-history-row-title {
    color: #e8edf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#page-notes .ed-preview .transclude-section {
    color: var(--accent);
    margin-left: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
}
#page-notes .ed-preview .transclude-status {
    color: var(--text-muted);
    font-size: 10px;
}
#page-notes .ed-preview .transclude-open,
#page-notes .ed-preview a.transclude-open {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font-size: 11px;
}
#page-notes .ed-preview .transclude-open:hover { text-decoration: underline; }
#page-notes .ed-preview .transclude-body {
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-primary);
}
#page-notes .ed-preview .transclude-body :first-child { margin-top: 0; }
#page-notes .ed-preview .transclude-body :last-child  { margin-bottom: 0; }
#page-notes .ed-preview .transclude-empty {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}
#page-notes .ed-preview .transclude-truncated {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ----- Sidebar settings link ---------------------------------- */

.notes-sidebar .ns-foot {
    margin-top: auto;
    padding: 8px 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.notes-sidebar .ns-settings-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
}
.notes-sidebar .ns-settings-link:hover {
    background: var(--surface);
    color: var(--text-primary);
}
.notes-sidebar .ns-settings-link .ns-link-icon {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
}

/* ----- Settings page ----------------------------------------- */

#page-notes .notes-settings-pane {
    flex: 1;
    overflow: auto;
    background: var(--bg-0);
}
#page-notes .settings-doc {
    max-width: 760px;
    margin: 0 auto;
    padding: 28px 36px 80px;
    color: var(--text-primary);
}
#page-notes .settings-head {
    margin-bottom: 32px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
#page-notes .settings-crumb {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
#page-notes .settings-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 0 0 6px;
    color: var(--text-primary);
}
#page-notes .settings-sub {
    color: var(--text-secondary);
    font-size: 13px;
}
#page-notes .settings-status {
    position: absolute;
    top: 0;
    right: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
#page-notes .settings-status.settings-status-err { color: var(--bad); }

#page-notes .settings-section {
    margin-bottom: 30px;
}
#page-notes .settings-h2 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin: 0 0 14px;
}
#page-notes .settings-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 8px;
}
#page-notes .settings-row-radio { align-items: flex-start; }
#page-notes .settings-row-text { flex: 1; min-width: 0; }
#page-notes .settings-row-label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 3px;
}
#page-notes .settings-row-hint {
    color: var(--text-secondary);
    font-size: 11.5px;
    line-height: 1.5;
}
#page-notes .settings-row-hint code {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
}

#page-notes .settings-input {
    width: 280px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-primary);
    padding: 7px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
}
#page-notes .settings-input:focus { outline: 0; border-color: var(--accent); }

#page-notes .settings-toggle {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
    flex-shrink: 0;
}
#page-notes .settings-toggle.on {
    background: rgba(79, 195, 247, .25);
    border-color: var(--accent);
}
#page-notes .settings-toggle .settings-toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: left .15s ease, background .15s ease;
}
#page-notes .settings-toggle.on .settings-toggle-knob {
    left: 20px;
    background: var(--accent);
}

#page-notes .settings-radio-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 280px;
}
#page-notes .settings-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-1);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
}
#page-notes .settings-radio.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(79, 195, 247, .07);
}
#page-notes .settings-radio input { accent-color: var(--accent); }

#page-notes .settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 14px;
    margin-bottom: 12px;
}
#page-notes .settings-card-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}
#page-notes .settings-card-row:last-child { margin-bottom: 0; }
#page-notes .settings-card-text { flex: 1; min-width: 0; }
#page-notes .settings-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 3px;
}
#page-notes .settings-card-sub {
    font-size: 11.5px;
    color: var(--text-secondary);
}
#page-notes .settings-btn {
    padding: 7px 14px;
    background: var(--accent);
    color: var(--bg-0);
    border: 0;
    border-radius: 3px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
}
#page-notes .settings-btn:hover { background: var(--accent-hot); }

#page-notes .settings-drop {
    border: 1.5px dashed var(--border-strong);
    border-radius: 4px;
    padding: 24px 14px;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}
#page-notes .settings-drop:hover,
#page-notes .settings-drop.hover {
    border-color: var(--accent);
    background: rgba(79, 195, 247, .04);
}
#page-notes .settings-drop-icon {
    font-size: 22px;
    margin-bottom: 6px;
    color: var(--text-muted);
}
#page-notes .settings-drop-label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}
#page-notes .settings-drop-sub {
    color: var(--text-muted);
    font-size: 11px;
}
#page-notes .settings-import-result {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}
#page-notes .settings-import-progress { color: var(--text-secondary); }
#page-notes .settings-import-ok       { color: var(--good); }
#page-notes .settings-import-err      { color: var(--bad); }
.ed-history-kind {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.1em;
    padding: 2px 5px;
    border-radius: 2px;
    background: #1e2228;
    color: #8a95a5;
}
.ed-history-kind-restore { color: #4fc3f7; background: rgba(79, 195, 247, 0.12); }
.ed-history-kind-import { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
.ed-history-kind-auto   { color: #8a95a5; }
.ed-history-preview {
    overflow-y: auto;
    padding: 18px 22px;
}
.ed-history-preview-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 12px;
    color: #e8edf3;
}
.ed-history-preview-md {
    font-size: 14px;
    line-height: 1.65;
    color: #e8edf3;
}
.ed-history-preview-md h1,
.ed-history-preview-md h2,
.ed-history-preview-md h3 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    color: #e8edf3;
}
.ed-history-preview-md a.wikilink {
    color: #4fc3f7;
    text-decoration: underline dotted;
}
.ed-history-empty,
.ed-history-loading,
.ed-history-error {
    color: #8a95a5;
    font-size: 13px;
    padding: 20px;
}
.ed-history-error { color: #f87171; }
.ed-history-foot {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid #2a313b;
    background: #0a0d12;
}
.ed-history-hint { font-size: 11px; color: #5a6472; }
.ed-history-restore[disabled] { opacity: 0.45; cursor: default; }


/* ─── Highlight-to-create-card popover ─── */
.ed-card-popover {
    z-index: 18500;
    background: #0a0d12;
    border: 1px solid #4fc3f7;
    border-radius: 6px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
    padding: 0;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
}
.ed-card-add {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent;
    border: 0;
    color: #4fc3f7;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
}
.ed-card-add:hover { background: rgba(79, 195, 247, 0.10); color: #e8edf3; }
.ed-card-add-icon {
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
}


/* ─── SRS review session ─── */
.notes-review-host {
    height: 100%;
    overflow: auto;
    padding: 20px 24px;
    color: var(--text-primary, #e8edf3);
}
.notes-review-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(2, 6, 12, 0.82);
    z-index: 19500;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Inter', system-ui, sans-serif;
    color: #e8edf3;
}
.notes-review-modal {
    width: min(720px, 92vw);
    max-height: min(720px, 92vh);
    background: #0f131a;
    border: 1px solid #2a313b;
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}
.notes-review-modal .notes-review-host {
    flex: 1;
    overflow: auto;
    padding: 28px 32px 32px;
}
.notes-review-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: 0;
    color: #8a95a5;
    font-size: 22px;
    cursor: pointer;
    z-index: 1;
    line-height: 1;
}
.notes-review-close:hover { color: #e8edf3; }
#page-notes .notes-review-host { background: var(--bg-0); }
.rev-wrap { max-width: 720px; margin: 0 auto; }

.rev-progress {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 18px;
    font-size: 12px;
    color: #8a95a5;
}
.rev-progress-text {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #4fc3f7;
    flex-shrink: 0;
}
.rev-progress-bar {
    flex: 1;
    height: 4px;
    background: #1e2228;
    border-radius: 2px;
    overflow: hidden;
}
.rev-progress-fill {
    height: 100%;
    background: linear-gradient(to right, #4fc3f7, #2bb0e8);
    transition: width 0.18s ease;
}
.rev-progress-counts {
    display: flex; gap: 10px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: #8a95a5;
}

.rev-card {
    background: #161b22;
    border: 1px solid #2a313b;
    border-radius: 8px;
    padding: 26px 28px;
    margin-bottom: 18px;
    position: relative;
}
.rev-note-ctx {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    color: #8a95a5;
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.rev-note-folder { color: #5a6472; }
.rev-note-link {
    color: #4fc3f7;
    cursor: pointer;
    text-decoration: none;
}
.rev-note-link:hover { text-decoration: underline; }
.rev-note-sep { color: #5a6472; }
.rev-state-pill {
    position: absolute;
    top: 14px; right: 16px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 2px;
}
.rev-pill-new {
    background: rgba(79, 195, 247, 0.14);
    color: #4fc3f7;
}
.rev-pill-mature {
    background: #1e2228;
    color: #8a95a5;
}
.rev-question {
    font-size: 19px;
    line-height: 1.5;
    color: #e8edf3;
    white-space: pre-wrap;
    margin: 14px 0 18px;
    font-weight: 500;
}
.rev-answer {
    border-top: 1px dashed #2a313b;
    padding-top: 16px;
    min-height: 60px;
}
.rev-show-btn {
    background: transparent;
    border: 1px dashed #4fc3f7;
    color: #4fc3f7;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    width: 100%;
}
.rev-show-btn:hover {
    background: rgba(79, 195, 247, 0.08);
    color: #e8edf3;
}
.rev-revealed {
    border-top-style: solid;
    border-top-color: #4fc3f7;
}
.rev-answer-text {
    font-size: 17px;
    line-height: 1.55;
    color: #4ade80;
    white-space: pre-wrap;
    font-weight: 500;
}

.rev-grade-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 14px;
}
.rev-grade {
    position: relative;
    padding: 14px 8px 18px;
    border: 1px solid #2a313b;
    background: #161b22;
    color: #e8edf3;
    border-radius: 6px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.05s ease, border-color 0.1s ease;
}
.rev-grade:hover { transform: translateY(-1px); }
.rev-grade-key {
    display: block;
    margin-top: 4px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0;
    color: #5a6472;
    text-transform: none;
}
.rev-grade-again { border-color: rgba(248, 113, 113, 0.45); color: #f87171; }
.rev-grade-again:hover { border-color: #f87171; background: rgba(248, 113, 113, 0.06); }
.rev-grade-hard  { border-color: rgba(251, 191, 36, 0.45); color: #fbbf24; }
.rev-grade-hard:hover  { border-color: #fbbf24; background: rgba(251, 191, 36, 0.06); }
.rev-grade-good  { border-color: rgba(74, 222, 128, 0.45); color: #4ade80; }
.rev-grade-good:hover  { border-color: #4ade80; background: rgba(74, 222, 128, 0.06); }
.rev-grade-easy  { border-color: rgba(79, 195, 247, 0.45); color: #4fc3f7; }
.rev-grade-easy:hover  { border-color: #4fc3f7; background: rgba(79, 195, 247, 0.06); }

.rev-grade-help {
    margin-top: 10px;
    font-size: 11px;
    color: #5a6472;
    text-align: center;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.rev-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid #1e2228;
}
.rev-suspend-btn,
.rev-skip-btn {
    background: transparent;
    border: 1px solid #2a313b;
    color: #8a95a5;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    letter-spacing: 0.04em;
    cursor: pointer;
}
.rev-suspend-btn:hover,
.rev-skip-btn:hover {
    color: #e8edf3;
    border-color: #3a4250;
}

.rev-empty,
.rev-error {
    text-align: center;
    padding: 60px 20px;
}
.rev-empty-glyph,
.rev-error-icon {
    font-size: 48px;
    margin-bottom: 14px;
}
.rev-empty-glyph { color: #4ade80; }
.rev-error-icon { color: #f87171; }
.rev-empty-title,
.rev-error-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: #e8edf3;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.rev-empty-body,
.rev-error-body {
    font-size: 14px;
    color: #8a95a5;
    max-width: 420px;
    margin: 0 auto;
    line-height: 1.55;
}
.rev-done-summary {
    margin-top: 18px;
    font-size: 13px;
    color: #4fc3f7;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.rev-done-mix {
    display: block;
    margin-top: 4px;
    color: #8a95a5;
    font-size: 11px;
}


/* ─── Right-rail "Spaced review" widget ─── */
#page-notes .nr-review-widget .nr-body { padding: 8px 12px 12px; }
#page-notes .nr-review-cta {
    width: 100%;
    background: linear-gradient(135deg, rgba(79, 195, 247, 0.16), rgba(43, 176, 232, 0.10));
    border: 1px solid rgba(79, 195, 247, 0.45);
    color: #e8edf3;
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    font-family: 'Inter', system-ui, sans-serif;
    transition: border-color 0.1s ease, transform 0.05s ease;
}
#page-notes .nr-review-cta:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
#page-notes .nr-review-count {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 26px;
    color: var(--accent);
    line-height: 1;
}
#page-notes .nr-review-label {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
#page-notes .nr-review-go {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}
#page-notes .nr-review-zero {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 4px 0;
}
#page-notes .nr-review-zero-glyph {
    color: var(--good);
    font-size: 18px;
    line-height: 1;
}
#page-notes .nr-review-zero-text {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* ====================================================================
 * Quick-capture sidebar — GLOBAL (mounts on document.body, not scoped
 * to #page-notes). Visible on every page once the user is signed in.
 * Keep tokens inlined since this can render on top of any other page's
 * stylesheet. Reuses the dashboard/notes color palette.
 * ==================================================================== */

.qb-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9000;
    padding: 14px 6px;
    background: #161b22;
    border: 1px solid #2a313b;
    border-left: 0;
    border-radius: 0 6px 6px 0;
    color: #8a95a5;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s, transform 0.18s;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35);
}
.qb-toggle:hover {
    background: #1e2228;
    color: #e8edf3;
    transform: translateY(-50%) translateX(2px);
}
.qb-toggle.on {
    background: #4fc3f7;
    color: #06121a;
    border-color: #4fc3f7;
}
.qb-toggle-icon { font-size: 16px; line-height: 1; }
.qb-toggle-label {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 700;
    font-size: 9px;
    letter-spacing: 0.18em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.notes-quickbar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    z-index: 8999;
    background: #0f131a;
    border-right: 1px solid #2a313b;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notes-quickbar.open { transform: translateX(0); }

/* Desktop Electron app draws an in-DOM titlebar — push the bar and pin
 * down so they don't overlap the drag handle / close button. */
body.is-desktop .notes-quickbar { top: 32px; }
body.is-desktop .qb-toggle { top: calc(50% + 16px); }

/* ====================================================================
 * Note picker — a global modal returning a chosen note via Promise.
 * Used by canvas's "+ Note" button and (future) wikilink autocomplete.
 * ==================================================================== */

.note-picker {
    position: fixed; inset: 0; z-index: 9500;
    display: none;
    align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    font-family: 'Inter', system-ui, sans-serif;
    color: #e8edf3;
}
.note-picker-backdrop {
    position: absolute; inset: 0;
    background: rgba(10, 13, 18, 0.65);
    backdrop-filter: blur(2px);
}
.note-picker-card {
    position: relative;
    width: 540px;
    max-width: calc(100vw - 32px);
    max-height: 70vh;
    background: #161b22;
    border: 1px solid #2a313b;
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.note-picker-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #2a313b;
}
.note-picker-icon { color: #4fc3f7; font-size: 16px; }
.note-picker-input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: none;
    color: #e8edf3;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 16px;
}
.note-picker-input::placeholder { color: #5a6472; }
.note-picker-key {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    padding: 2px 6px;
    background: #0a0d12;
    border: 1px solid #2a313b;
    border-radius: 3px;
    color: #5a6472;
}
.note-picker-results {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    min-height: 80px;
}
.note-picker-row {
    padding: 8px 16px;
    cursor: pointer;
    border-left: 2px solid transparent;
}
.note-picker-row.sel {
    background: #1e2228;
    border-left-color: #4fc3f7;
}
.note-picker-row-title {
    font-size: 13px;
    color: #e8edf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.note-picker-row-meta {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
    margin-top: 2px;
}
.note-picker-loading,
.note-picker-empty {
    padding: 16px;
    text-align: center;
    color: #5a6472;
    font-size: 12px;
    font-style: italic;
}
.note-picker-foot {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid #2a313b;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
}
.note-picker-foot kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9px;
    padding: 1px 4px;
    background: #0a0d12;
    border: 1px solid #2a313b;
    border-radius: 2px;
    color: #8a95a5;
    margin-right: 4px;
}

/* Push the toggle out of the way when the bar is open. */
.notes-quickbar.open ~ .qb-toggle,
body.qb-open .qb-toggle {
    left: 380px;
    box-shadow: none;
}

.qb-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #2a313b;
    flex-shrink: 0;
}
.qb-head-titles { flex: 1; min-width: 0; }
.qb-eyebrow {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.18em;
    color: #4fc3f7;
    margin-bottom: 6px;
}
.qb-title-row { display: flex; }
.qb-title {
    flex: 1;
    background: transparent;
    border: 0;
    color: #e8edf3;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.01em;
    padding: 4px 0;
    outline: none;
}
.qb-title::placeholder { color: #5a6472; }
.qb-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.qb-link {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #8a95a5;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #2a313b;
    transition: color 0.15s, border-color 0.15s;
}
.qb-link:hover { color: #4fc3f7; border-color: #4fc3f7; }
.qb-close {
    width: 26px; height: 26px;
    background: transparent;
    border: 1px solid #2a313b;
    color: #8a95a5;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.qb-close:hover { color: #e8edf3; border-color: #3a4250; }

.qb-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
    border-bottom: 1px solid #2a313b;
    flex-shrink: 0;
}
.qb-status { color: #8a95a5; }
.qb-status.qb-status-err { color: #f87171; }
.qb-hint kbd {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9px;
    padding: 1px 4px;
    background: #0a0d12;
    border: 1px solid #2a313b;
    border-radius: 2px;
    color: #8a95a5;
}

/* Category chips — toggle a #tag in the body. Active when the body
 * already contains that tag. Tap to add (or remove) so the user can
 * later filter the vault by these "currently learning / tracking"
 * groupings. */
.qb-cat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 14px 8px;
    border-bottom: 1px solid #2a313b;
    background: #0f131a;
    flex-shrink: 0;
}
.qb-cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #2a313b;
    border-radius: 999px;
    color: #8a95a5;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.qb-cat:hover {
    color: #e8edf3;
    border-color: #3a4250;
}
.qb-cat .qb-cat-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #3a4250;
    transition: background 0.12s;
}
.qb-cat.on {
    color: #06121a;
    background: #4fc3f7;
    border-color: #4fc3f7;
}
.qb-cat.on .qb-cat-dot { background: #06121a; }

.qb-body {
    flex: 1;
    background: #0a0d12;
    border: 0;
    color: #e8edf3;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 14px 18px;
    resize: none;
    outline: none;
    tab-size: 2;
    overflow: auto;
}
.qb-body::placeholder {
    color: #5a6472;
    font-style: italic;
    line-height: 1.6;
}

.qb-foot {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #2a313b;
    flex-shrink: 0;
    background: #0f131a;
}
.qb-save, .qb-new, .qb-pin {
    padding: 8px 14px;
    border-radius: 4px;
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid #2a313b;
}
.qb-pin {
    background: transparent;
    color: #8a95a5;
}
.qb-pin:hover {
    color: #4fc3f7;
    border-color: #4fc3f7;
}
.qb-save {
    background: #4fc3f7;
    color: #06121a;
    border-color: #4fc3f7;
    flex: 1;
}
.qb-save:hover { background: #2bb0e8; border-color: #2bb0e8; }
.qb-save.qb-save-pulse {
    animation: qb-pulse 0.5s ease-out;
}
@keyframes qb-pulse {
    0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 195, 247, 0.6); }
    40%  { transform: scale(0.97); box-shadow: 0 0 0 8px rgba(79, 195, 247, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(79, 195, 247, 0); }
}
.qb-new {
    background: transparent;
    color: #8a95a5;
}
.qb-new:hover { color: #e8edf3; border-color: #3a4250; }

.qb-recent {
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid #2a313b;
    background: #0f131a;
    flex-shrink: 0;
}
.qb-recent-head {
    font-family: 'Rajdhani', system-ui, sans-serif;
    font-weight: 700;
    font-size: 9px;
    letter-spacing: 0.18em;
    color: #5a6472;
    padding: 10px 16px 6px;
}
.qb-recent-list { padding: 0 8px 10px; }
.qb-recent-item {
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
}
.qb-recent-item:hover { background: #161b22; }
.qb-recent-title {
    font-size: 12px;
    color: #e8edf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qb-recent-meta {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    color: #5a6472;
    margin-top: 2px;
}
.qb-recent-empty {
    padding: 8px 12px;
    font-size: 11px;
    color: #5a6472;
    font-style: italic;
}

@media (max-width: 720px) {
    .notes-quickbar { width: 100vw; }
    .notes-quickbar.open ~ .qb-toggle,
    body.qb-open .qb-toggle { left: 0; opacity: 0; pointer-events: none; }
}
