/* ══════════════════════════════════════════════════════════════════
   UNIFIED NOTES — scratchpad + note cards + distraction-free editor
══════════════════════════════════════════════════════════════════ */

/* View Routing — now handled by notes-mode in styles.css */

/* Search */
.cn-search-wrap { display: block !important; max-height: 0; opacity: 0; overflow: hidden; margin-bottom: 0; pointer-events: none; transition: max-height 0.28s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.22s ease, margin 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
.cn-search-wrap.open { max-height: 60px; opacity: 1; margin-bottom: 12px; overflow: visible; pointer-events: auto; }

/* Filter row */
.cn-filter-row { display: flex; gap: 6px; margin-bottom: 16px; margin-left: -20px; margin-right: -20px; padding: 4px 20px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.cn-filter-row::-webkit-scrollbar { display: none; }

/* ── SCRATCHPAD AREA ── */
.cn-scratch-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  margin-bottom: 18px;
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-base);
}

.cn-scratch-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}

.cn-scratch-label {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted); font-weight: 700;
}

.cn-scratch-right { display: flex; gap: 8px; align-items: center; }

.cn-scratch-sync {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
}

.cn-scratch-mono {
  font-size: 10px; color: var(--text-muted); cursor: pointer; padding: 2px 8px;
  border: 1px solid var(--border-main); border-radius: 6px; font-family: var(--font-mono);
  -webkit-user-select: none; user-select: none;
}
.cn-scratch-mono.mono-active { color: var(--accent); border-color: var(--accent-faded); }

.cn-scratch-textarea {
  width: 100%; min-height: 80px; max-height: 200px;
  background: transparent; border: none; outline: none; resize: vertical;
  color: var(--text-main); -webkit-text-fill-color: var(--text-main);
  font-family: var(--font-main); font-size: 14px; line-height: 1.7;
  box-sizing: border-box; padding: 0;
}
.cn-scratch-textarea::placeholder { color: var(--text-muted); opacity: 0.6; }
.cn-scratch-textarea.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── NOTE CARDS ── */
.cn-note-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.1s, transform 0.12s ease;
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  box-shadow: var(--shadow-base);
  opacity: 0;
}
.cn-note-card.entering {
  animation: taskIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.cn-note-card:active { transform: scale(0.98); }

.cn-note-card .cn-card-title {
  font-size: 14px; font-weight: 600; color: var(--text-main);
  margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cn-note-card .cn-card-speaker {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.cn-note-card .cn-card-preview {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px;
}

.cn-note-card .cn-card-meta {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}

.cn-note-card .cn-card-time {
  font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-left: auto;
}

.cn-card-pin {
  font-size: 11px; margin-right: 4px;
}

/* Pin button in editor topbar */
.cn-pin-btn { border-color: transparent; background: transparent; transition: all 0.15s ease; }
.cn-pin-btn:active { transform: scale(0.85); }
.cn-pin-btn svg { width: 14px; height: 14px; stroke: var(--text-muted); transition: stroke 0.15s; }
.cn-pin-btn.pinned { background: var(--accent-faded); border-color: var(--accent); }
.cn-pin-btn.pinned svg { stroke: var(--accent); }

.cn-empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.cn-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.cn-empty-text { font-size: 13px; line-height: 1.6; }

/* ── DISTRACTION-FREE EDITOR ── */
.cn-detail-fullscreen {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 60px);
  min-height: calc(100dvh - 60px);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  overflow: visible;
}

/* Note open/close transitions */
@keyframes cnDetailIn {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cnDetailOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(40px); }
}
@keyframes cnListIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cn-detail-enter {
  animation: cnDetailIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.cn-detail-exit {
  animation: cnDetailOut 0.2s cubic-bezier(0.4, 0, 1, 1) both;
}
.cn-list-enter {
  animation: cnListIn 0.2s ease both;
}

.cn-detail-topbar {
  display: flex; align-items: center; margin-bottom: 12px;
  position: sticky; top: 0; z-index: 10;
  padding: 4px 0;
}

.cn-detail-topbar-title {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
}

.cn-detail-title-input {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text-main); -webkit-text-fill-color: var(--text-main);
  font-family: var(--font-main); font-size: 22px; font-weight: 600;
  line-height: 1.2; margin-bottom: 6px; padding: 0;
}
.cn-detail-title-input::placeholder { color: var(--text-muted); opacity: 0.5; }

.cn-detail-source-input {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text-muted); -webkit-text-fill-color: var(--text-muted);
  font-family: var(--font-mono); font-size: 12px;
  margin-bottom: 12px; padding: 0;
}
.cn-detail-source-input::placeholder { color: var(--text-muted); opacity: 0.4; }

/* Collapsible metadata drawer */
.cn-detail-meta-drawer {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-divider);
  padding-bottom: 12px;
}

.cn-detail-meta-toggle {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  color: var(--text-muted); cursor: pointer; padding: 4px 0;
  -webkit-user-select: none; user-select: none; list-style: none;
}
.cn-detail-meta-toggle::-webkit-details-marker { display: none; }
.cn-detail-meta-toggle::before {
  content: '▸ '; font-size: 9px;
}
.cn-detail-meta-drawer[open] .cn-detail-meta-toggle::before { content: '▾ '; }

.cn-detail-meta-content {
  padding-top: 10px;
}

.cn-detail-body-input {
  width: 100%; min-height: 120px;
  background: transparent; border: none; outline: none; resize: none;
  color: var(--text-main); -webkit-text-fill-color: var(--text-main);
  font-family: var(--font-main); font-size: 15px; line-height: 1.8;
  box-sizing: border-box; padding: 0;
  overflow: hidden;
}
.cn-detail-body-input::placeholder { color: var(--text-muted); opacity: 0.4; }
.cn-detail-body-input.mono { font-family: var(--font-mono); font-size: 13px; }

.cn-detail-meta {
  font-size: 10px; color: var(--text-muted); font-family: var(--font-mono);
  margin-top: 6px; padding-top: 6px;
}

/* ── MARKDOWN PREVIEW ── */
.cn-md-preview {
  min-height: 120px;
  color: var(--text-main);
  font-family: var(--font-main); font-size: 15px; line-height: 1.8;
  padding: 0;
}
.cn-md-preview h1, .cn-md-preview h2, .cn-md-preview h3,
.cn-md-preview h4, .cn-md-preview h5, .cn-md-preview h6 {
  color: var(--text-main); margin: 1em 0 0.4em; line-height: 1.3;
}
.cn-md-preview h1 { font-size: 1.4em; font-weight: 700; }
.cn-md-preview h2 { font-size: 1.2em; font-weight: 600; }
.cn-md-preview h3 { font-size: 1.05em; font-weight: 600; }
.cn-md-preview p { margin: 0 0 0.8em; }
.cn-md-preview ul, .cn-md-preview ol { padding-left: 1.4em; margin: 0 0 0.8em; }
.cn-md-preview li { margin-bottom: 0.25em; }
.cn-md-preview li > ul, .cn-md-preview li > ol { margin-bottom: 0; }
.cn-md-preview code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--accent-faded); padding: 1px 5px; border-radius: 4px;
}
.cn-md-preview pre {
  background: var(--bg-input); border: 1px solid var(--border-main);
  border-radius: 8px; padding: 12px 14px; overflow-x: auto;
  margin: 0 0 0.8em; line-height: 1.5;
}
.cn-md-preview pre code {
  background: none; padding: 0; font-size: 12px;
}
.cn-md-preview blockquote {
  border-left: 3px solid var(--accent); margin: 0 0 0.8em;
  padding: 2px 0 2px 14px; color: var(--text-muted);
}
.cn-md-preview hr {
  border: none; border-top: 1px solid var(--border-divider);
  margin: 1.2em 0;
}
.cn-md-preview a { color: var(--accent); text-decoration: underline; }
.cn-md-preview strong { font-weight: 600; }
.cn-md-preview table {
  border-collapse: collapse; width: 100%; margin: 0 0 0.8em;
  font-size: 0.9em;
}
.cn-md-preview th, .cn-md-preview td {
  border: 1px solid var(--border-divider); padding: 6px 10px; text-align: left;
}
.cn-md-preview th { font-weight: 600; background: var(--bg-input); }
.cn-md-preview img { max-width: 100%; border-radius: 8px; }

/* Toggle button active state */
.cn-scratch-mono.md-active { color: var(--accent); border-color: var(--accent-faded); }

/* Desktop padding */
@media (min-width: 768px) {
  #confNotesView { padding: 0 32px 14px; }
}
@media (min-width: 1100px) {
  #confNotesView { padding: 0 40px 14px; }
}

/* Deep focus: hide notes */
body.deep-focus-mode #confNotesView { display: none !important; }

/* ── Lock button ── */
.cn-lock-btn { border-color: transparent; background: transparent; transition: all 0.15s ease; }
.cn-lock-btn:active { transform: scale(0.85); }
.cn-lock-btn svg { width: 14px; height: 14px; stroke: var(--text-muted); transition: stroke 0.15s; }
.cn-lock-btn.locked { background: rgba(255, 149, 0, 0.12); border-color: rgba(255, 149, 0, 0.4); }
.cn-lock-btn.locked svg { stroke: #ff9500; }

/* ── Locked note card ── */
.cn-note-card.locked-card .cn-card-preview {
  filter: blur(6px);
  -webkit-filter: blur(6px);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.cn-card-lock-icon {
  font-size: 11px;
  margin-right: 4px;
  opacity: 0.7;
}

/* ── PIN modal ── */
.pin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pin-modal {
  background: var(--bg-surface, #1c1c1e);
  border: 1px solid var(--border-main, rgba(255,255,255,0.08));
  border-radius: 18px;
  padding: 28px 24px 22px;
  width: 100%;
  max-width: 300px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
}
.pin-modal-title {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text-primary, #fff);
}
.pin-modal-input {
  width: 100%;
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.3em;
  font-family: var(--font-mono);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-main, rgba(255,255,255,0.12));
  background: var(--bg-card, rgba(255,255,255,0.04));
  color: var(--text-primary, #fff);
  margin-bottom: 8px;
  outline: none;
  box-sizing: border-box;
}
.pin-modal-input:focus {
  border-color: var(--accent, #007aff);
}
.pin-modal-error {
  font-size: 12px;
  color: #ff3a30;
  text-align: center;
  min-height: 18px;
  margin-bottom: 12px;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════════════════════════════════
   NOTE TYPES — paper, idea, memo
══════════════════════════════════════════════════════════════════ */

/* ── Type filter row (list view) ── */
.cn-type-filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  margin-left: -20px;
  margin-right: -20px;
  padding: 4px 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cn-type-filter-row::-webkit-scrollbar { display: none; }

/* ── Type badges on cards ── */
.cn-type-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.cn-type-badge-memo {
  background: rgba(128,128,128,0.1);
  color: var(--text-muted);
}
.cn-type-badge-paper {
  background: rgba(175, 82, 222, 0.12);
  color: #af52de;
}
.cn-type-badge-idea {
  background: rgba(255, 149, 0, 0.12);
  color: #ff9500;
}

/* ── Card left-border accent by type ── */
.cn-note-card.cn-type-paper {
  border-left: 3px solid rgba(175, 82, 222, 0.5);
}
.cn-note-card.cn-type-idea {
  border-left: 3px solid rgba(255, 149, 0, 0.5);
}

/* ── Idea status badges ── */
.cn-idea-status {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.cn-idea-status-raw {
  background: rgba(255, 149, 0, 0.1);
  color: #ff9500;
}
.cn-idea-status-developing {
  background: rgba(48, 209, 88, 0.1);
  color: #30d158;
}
.cn-idea-status-ready-to-pitch {
  background: rgba(0, 122, 255, 0.1);
  color: #007aff;
}

/* ── Stale / cooling indicators ── */
.cn-idea-stale {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 58, 48, 0.1);
  color: #ff3a30;
  white-space: nowrap;
}
.cn-idea-cooling {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 159, 10, 0.1);
  color: #ff9f0a;
  white-space: nowrap;
}

/* ── Paper URL badge ── */
.cn-paper-url-badge {
  font-size: 10px;
  margin-right: 3px;
  opacity: 0.7;
}

/* ── Type selector in editor ── */
.cn-type-selector {
  display: flex;
  gap: 6px;
  padding: 0 20px 10px;
}
.cn-type-chip {
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-divider, rgba(255,255,255,0.08));
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.cn-type-chip.active {
  background: var(--accent-faded, rgba(0,122,255,0.1));
  border-color: var(--accent, #007aff);
  color: var(--accent, #007aff);
}
.cn-type-chip[data-type="paper"].active {
  background: rgba(175, 82, 222, 0.12);
  border-color: #af52de;
  color: #af52de;
}
.cn-type-chip[data-type="idea"].active {
  background: rgba(255, 149, 0, 0.12);
  border-color: #ff9500;
  color: #ff9500;
}

/* ── URL row (papers) ── */
.cn-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px 8px;
}
.cn-url-label {
  font-size: 13px;
  opacity: 0.6;
  flex-shrink: 0;
}

/* ── Idea status row ── */
.cn-idea-status-row {
  display: flex;
  gap: 6px;
  padding: 0 20px 10px;
}
.cn-status-chip {
  padding: 3px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-divider, rgba(255,255,255,0.08));
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.cn-status-chip.active {
  color: #ff9500;
  border-color: rgba(255, 149, 0, 0.4);
  background: rgba(255, 149, 0, 0.1);
}
.cn-status-chip[data-status="developing"].active {
  color: #30d158;
  border-color: rgba(48, 209, 88, 0.4);
  background: rgba(48, 209, 88, 0.1);
}
.cn-status-chip[data-status="ready to pitch"].active {
  color: #007aff;
  border-color: rgba(0, 122, 255, 0.4);
  background: rgba(0, 122, 255, 0.1);
}

/* ── New note type menu ── */
.cn-new-menu {
  position: fixed;
  bottom: calc(84px + env(safe-area-inset-bottom));
  right: 20px;
  background: var(--bg-surface, #1c1c1e);
  border: 1px solid var(--border-main, rgba(255,255,255,0.08));
  border-radius: 14px;
  padding: 6px 0;
  z-index: 200;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  backdrop-filter: var(--glass-filter, blur(24px));
  -webkit-backdrop-filter: var(--glass-filter, blur(24px));
  animation: cn-menu-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes cn-menu-in {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cn-new-menu-item {
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
.cn-new-menu-item:active {
  background: var(--accent-faded, rgba(0,122,255,0.1));
}
.cn-new-icon {
  font-size: 15px;
  width: 22px;
  text-align: center;
}

/* Desktop max-width for new menu */
@media (min-width: 769px) {
  .cn-new-menu { right: calc(50% - 360px + 24px); }
}
@media (min-width: 1100px) {
  .cn-new-menu { right: calc(50% - 430px + 24px); }
}

/* ── Linked Notes Styling ── */
.internal-note-link {
  color: var(--accent, #007aff);
  background-color: var(--accent-faded, rgba(0, 122, 255, 0.1));
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-block;
  margin: 0 2px;
}

.internal-note-link:hover {
  background-color: rgba(0, 122, 255, 0.25);
  text-decoration: none;
}

/* ── Auto-Injected Markdown Paper Link (Redesigned) ── */
.cn-md-paper-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-main, 'DM Sans', sans-serif);
    font-size: 13px;
    color: var(--text-main, #fff) !important;
    background: transparent;
    border: 1px solid var(--border-divider, rgba(255,255,255,0.15));
    padding: 8px 14px;
    border-radius: 10px;
    text-decoration: none !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cn-md-paper-link:hover {
    border-color: rgba(175, 82, 222, 0.4);
    background: rgba(175, 82, 222, 0.05);
}

.cn-md-paper-link:active {
    transform: scale(0.98);
}

/* ── NOTES GRID VIEW ("APPLE NOTES" STYLE) ── */
.cn-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-items: start;
}

.cn-grid-view .cn-note-card {
    margin-bottom: 0;
    height: 160px; /* Forces all boxes to be uniform height */
    display: flex;
    flex-direction: column;
}

.cn-grid-view .cn-card-title {
    white-space: normal; /* Allow title to wrap to two lines in grid mode */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cn-grid-view .cn-card-preview {
    flex: 1; /* Pushes the meta tags to the absolute bottom of the card */
    -webkit-line-clamp: 3; /* Shows slightly more text preview in box mode */
}

.cn-grid-view .cn-card-meta {
    margin-top: auto;
    overflow: hidden; /* Prevent long tags from breaking the box layout */
    flex-wrap: nowrap;
}

.cn-grid-view .cn-card-time {
    display: none; /* Hide timestamp in grid mode to keep boxes perfectly clean */
}

/* ══════════════════════════════════════════════════════════════════
   BACKLINKS DRAWER
══════════════════════════════════════════════════════════════════ */

.cn-backlinks-drawer {
  margin-top: 8px;
  border-top: 1px solid var(--border-divider);
}

.cn-backlinks-toggle {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  cursor: pointer;
  padding: 12px 0 10px;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  transition: color 0.15s;
}

.cn-backlinks-arrow {
  font-size: 9px;
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  flex-shrink: 0;
}

.cn-backlinks-label-text {
  flex: 1;
}

.cn-backlinks-count {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-faded);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.cn-backlinks-list {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 24px;
}

.cn-backlinks-drawer.open .cn-backlinks-list {
  display: flex;
  animation: cnBlIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

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

/* Individual backlink row */
.cn-backlink-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-main);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s, transform 0.12s ease;
  box-shadow: var(--shadow-base);
  position: relative;
  overflow: hidden;
}

.cn-backlink-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0.5;
}

.cn-backlink-item.cn-backlink-type-paper::before { background: #af52de; }
.cn-backlink-item.cn-backlink-type-idea::before  { background: #ff9500; }
.cn-backlink-item.cn-backlink-type-memo::before  { background: var(--accent); }

.cn-backlink-item:active { transform: scale(0.98); }

.cn-backlink-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.75;
}

.cn-backlink-body {
  flex: 1;
  min-width: 0;
}

.cn-backlink-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
  font-family: var(--font-main);
}

.cn-backlink-context {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-serif);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cn-backlink-context mark {
  background: var(--accent-faded);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
  font-style: normal;
}

.cn-backlink-type-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.cn-bl-badge-paper { background: rgba(175, 82, 222, 0.12); color: #af52de; }
.cn-bl-badge-idea  { background: rgba(255, 149, 0, 0.12);  color: #ff9500; }
.cn-bl-badge-memo  { background: rgba(128, 128, 128, 0.1); color: var(--text-muted); }

.cn-backlinks-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  padding: 4px 0 14px;
  text-align: center;
  letter-spacing: 0.02em;
}
