/* —— редактор заметки ——
   Только токены: ни одного зашитого цвета, радиуса или длительности. */

.note-editor-page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: var(--sp-8);
}

/* Заголовок набирается дисплейным Unbounded. Разрядка положительная:
   в этой системе отрицательный трекинг запрещён — Unbounded на минусе
   слипается на «ж», «щ», «ю». */
.note-title-input {
  width: 100%;
  box-sizing: border-box;
  border: var(--bw-bold) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-hero);
  padding: var(--sp-1) var(--sp-2);
  outline: none;
  transition: border-color var(--t-fast) var(--e-out);
}

/* Поле без рамки в покое, поэтому фокус показываем самой рамкой:
   кольцо-тень здесь перекрывалось бы соседним textarea. */
.note-title-input:focus-visible {
  border-color: var(--accent);
}

.note-body-input {
  width: 100%;
  max-width: var(--measure);
  min-height: 42vh;
  box-sizing: border-box;
  resize: vertical;
  border: var(--bw-hair) solid var(--c-ink-3);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--ink);
  padding: var(--sp-4);
  font: inherit;
  font-size: var(--fs-body);
  line-height: var(--lh-loose);
  outline: none;
  transition:
    border-color var(--t-fast) var(--e-out),
    background var(--t-fast) var(--e-out);
}

/* Как .input в style.css: рамка толстеет, padding убавляется на прирост,
   текст под курсором не сдвигается ни на пиксель. */
.note-body-input:focus {
  border: var(--bw-bold) solid var(--accent);
  padding: calc(var(--sp-4) - 1px);
  background: var(--bg-raised);
}

.note-preview.md-body {
  max-width: var(--measure);
  min-height: 42vh;
  padding: var(--sp-4);
  border: var(--bw-hair) solid var(--c-ink-3);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--sh-1);
  line-height: var(--lh-loose);
}

.note-preview.md-body h1,
.note-preview.md-body h2,
.note-preview.md-body h3 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-hero);
  margin: 0.8em 0 0.35em;
  line-height: var(--lh-tight);
}

.note-preview.md-body p { margin: 0.55em 0; }
.note-preview.md-body ul,
.note-preview.md-body ol { padding-left: 1.3em; margin: 0.55em 0; }
.note-preview.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--c-ink) 8%, transparent);
  padding: 0.1em 0.35em;
  border-radius: var(--r-1);
}
.note-preview.md-body pre {
  overflow: auto;
  padding: var(--sp-3);
  border-radius: var(--r-2);
  background: color-mix(in srgb, var(--c-ink) 6%, transparent);
}
.note-preview.md-body pre code {
  background: none;
  padding: 0;
}

.note-save-status {
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Охряная плашка с чернильной подписью — в этой системе единственный
   допустимый способ применять охру, и конфликт правок ровно тот случай.
   Разметка та же, что у .offline-banner, поэтому и вид тот же. */
.note-conflict-banner {
  padding: var(--sp-3);
  border: var(--bw-bold) solid var(--c-ink);
  border-radius: var(--radius-sm);
  background: var(--c-ochre);
  color: var(--c-on-ochre);
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  text-align: left;
}

.note-conflicts,
.note-cards,
.note-memory {
  margin-top: var(--sp-2);
  padding: var(--sp-4);
  border: var(--bw-hair) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.note-conflicts h4,
.note-cards h4,
.note-memory h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-body);
  letter-spacing: var(--ls-hero);
  color: var(--ink);
}

.note-conflict-row,
.note-card-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  padding: var(--sp-2) 0;
  cursor: pointer;
  font: inherit;
}

.note-conflict-row:focus-visible,
.note-card-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.note-cards-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.note-cards-head h4 { margin: 0; }

/* Подсказка под заголовком: как связать карточку с заметкой. */
.note-cards-hint {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-small);
  line-height: var(--lh-snug);
}

.note-cards-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note-cards-list li {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  border-top: var(--bw-hair) solid var(--line);
  padding: var(--sp-2) 0;
}

.note-card-anchor {
  font-size: var(--fs-micro);
  color: var(--ink-faint);
}

/* —— meta, tags, toolbar, backlinks, md help —— */

.note-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  max-width: var(--measure);
}

.note-folder-label {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  font-size: var(--fs-small);
}

.note-folder-select,
.notes-filter-select {
  min-width: 12rem;
  border: var(--bw-hair) solid var(--c-ink-3);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--ink);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.note-tag-chip,
.md-tag {
  display: inline-flex;
  align-items: center;
  border: var(--bw-hair) solid var(--c-ink);
  border-radius: var(--r-1);
  background: var(--c-paper-2);
  color: var(--c-ink);
  padding: 0 var(--sp-2);
  font-size: var(--fs-micro);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-label);
  text-decoration: none;
  cursor: pointer;
}

.note-tags-empty { font-size: var(--fs-micro); }

.note-backlinks,
.note-unlinked {
  margin-top: var(--sp-2);
  padding: var(--sp-4);
  border: var(--bw-hair) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}

.note-backlinks h4,
.note-unlinked h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
}

.note-backlinks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-3);
}

.md-wiki {
  color: var(--c-petrol);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md-wiki--missing {
  color: var(--c-ink-2);
  text-decoration: underline dotted;
}

.md-figure {
  display: block;
  margin: var(--sp-3) 0;
}
.md-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: var(--bw-hair) solid var(--c-edge);
  border-radius: var(--r-1);
}
.md-figcaption {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--fs-small);
  color: var(--c-ink-2);
}

.note-md-help-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-2) var(--sp-4);
  margin: var(--sp-3) 0 0;
}
.note-md-help-list dt {
  font-size: var(--fs-small);
  color: var(--c-ink-2);
}
.note-md-help-list dd { margin: 0; }
.note-md-help-list code {
  font-size: var(--fs-small);
  background: var(--bg-sunken);
  padding: 0.1em 0.4em;
  border-radius: var(--r-1);
}

/* —— CodeMirror 6 + split-view —— */
.note-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  max-width: 100%;
  padding: var(--sp-1);
  border: var(--bw-hair) solid var(--c-edge);
  border-radius: var(--r-1);
  background: var(--c-paper-2);
}

.note-tool-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--c-ink-2);
  cursor: pointer;
}
.note-tool-btn svg { width: 18px; height: 18px; display: block; }
.note-tool-btn:hover { color: var(--c-ink); background: var(--c-paper-3); }
.note-tool-btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.note-tool-btn.is-active,
.note-mode-btn.is-active {
  color: var(--c-paper);
  background: var(--c-ink);
}

.note-mode-switch {
  display: inline-flex;
  border: var(--bw-hair) solid var(--c-ink);
  border-radius: var(--r-1);
  overflow: hidden;
}
.note-mode-switch .note-tool-btn {
  border-radius: 0;
  width: 34px;
  height: 34px;
}

.note-split {
  display: grid;
  gap: var(--sp-3);
  max-width: 100%;
  min-height: 42vh;
}
.note-split--edit {
  grid-template-columns: 1fr;
}
.note-split--edit .note-preview { display: none; }
.note-split--preview {
  grid-template-columns: 1fr;
}
.note-split--preview .note-cm-host { display: none; }
.note-split--split {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 719px) {
  .note-split--split {
    grid-template-columns: 1fr;
  }
}

.note-cm-host {
  min-height: 42vh;
  max-width: var(--measure);
  border: var(--bw-hair) solid var(--c-ink-3);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  overflow: hidden;
  transition:
    border-color var(--t-fast) var(--e-out),
    background var(--t-fast) var(--e-out),
    box-shadow var(--t-fast) var(--e-out);
}
.note-cm-host:focus-within {
  border: var(--bw-bold) solid var(--accent);
  background: var(--bg-raised);
  box-shadow: var(--sh-focus);
}
.note-split--split .note-cm-host,
.note-split--split .note-preview {
  max-width: none;
  min-height: 50vh;
}

.note-cm,
.note-cm .cm-editor {
  height: 100%;
  min-height: 42vh;
}
.note-cm .cm-scroller {
  min-height: 42vh;
}

.note-preview.md-body blockquote {
  margin: var(--sp-3) 0;
  padding: var(--sp-2) var(--sp-4);
  border-left: var(--bw-slab) solid var(--c-petrol);
  color: var(--c-ink-2);
  background: color-mix(in srgb, var(--c-ink) 4%, transparent);
}
.note-preview.md-body .md-task-list { list-style: none; padding-left: 0; }
.note-preview.md-body .md-task {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}
.note-preview.md-body .md-task input { margin-top: 0.35em; }

.note-preview.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-3) 0;
  font-size: var(--fs-small);
}
.note-preview.md-body th,
.note-preview.md-body td {
  border: var(--bw-hair) solid var(--c-edge);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
}
.note-preview.md-body th {
  background: color-mix(in srgb, var(--c-ink) 6%, transparent);
}
.note-preview.md-body del {
  color: var(--c-ink-2);
  text-decoration: line-through;
}

.md-embed {
  margin: var(--sp-3) 0;
  padding: var(--sp-3);
  border: var(--bw-hair) solid var(--c-edge);
  border-left: var(--bw-slab) solid var(--c-petrol);
  background: color-mix(in srgb, var(--c-ink) 3%, transparent);
  border-radius: var(--r-1);
}
.md-embed-open {
  display: inline-block;
  margin-bottom: var(--sp-2);
  font-size: var(--fs-small);
  font-weight: 600;
}
.md-embed-body { min-width: 0; }

.note-cm .cm-gutters { display: none; }
.note-cm--gutters .cm-gutters { display: flex; }

.note-local-graph {
  margin-top: var(--sp-5);
  max-width: 100%;
}
.note-local-graph-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.note-local-graph-head h4 { margin: 0; }
.note-local-graph-depth {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.note-local-graph-depth .btn.is-active {
  background: var(--c-ink);
  color: var(--c-paper);
}
.note-local-graph-stage {
  box-sizing: border-box;
  height: 280px;
  max-height: 280px;
  flex: 0 0 280px;
  border: var(--bw-hair) solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-raised);
  contain: strict;
}
.note-local-graph-stage .notes-graph-canvas,
.note-local-graph-stage .notes-graph-canvas--compact {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  height: 280px !important;
  max-height: 280px !important;
  min-height: 0 !important;
}

.note-backlink-item {
  display: grid;
  gap: var(--sp-1);
}
.note-backlink-snippet {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--fs-small);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-sunken);
  border-radius: var(--r-1);
  color: var(--c-ink-2);
}
.note-backlink-snippet mark {
  background: color-mix(in srgb, var(--c-petrol) 28%, transparent);
  color: var(--c-ink);
  padding: 0 0.1em;
}

.note-rename-list {
  max-height: 40vh;
  overflow: auto;
  margin: var(--sp-3) 0;
  padding-left: 1.2em;
}

.notes-row-preview mark {
  background: color-mix(in srgb, var(--c-petrol) 28%, transparent);
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}

/* —— memory-панель на экране заметки —— */
.note-memory:empty { display: none; }
.note-memory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.note-memory-head h4 { margin: 0; }
.note-memory-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-2) 0;
}
.note-memory-summary {
  font-size: var(--fs-small);
  color: var(--c-ink-2);
}
.note-memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.note-memory-empty p {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--c-ink-2);
}
