/* Форматирование заметок: панель над клавиатурой, подсветка в редакторе, оформленный вид (079-note-*.js, 105-note.js, 114-notes-shell.js). Только токены. */

/* ---------- поле с подсветкой: зеркало лежит под полем, у поля прозрачные буквы ---------- */
#note .nt-field { position: relative; display: flow-root; margin-top: var(--sp-12); }
#note .nt-field .nt-text { margin-top: 0; position: relative; z-index: 1; }
#note .nt-field-add { margin-top: var(--sp-4); }
#note .nt-field-add .nt-add-text { margin: 0; position: relative; z-index: 1; }
.nt-mirror {
  position: absolute; inset: 0; z-index: 0; margin: 0; padding: 0; overflow: hidden; pointer-events: none;
  white-space: pre-wrap; overflow-wrap: break-word; font-family: var(--font-ui); font-size: var(--fs-lead); line-height: var(--lh-note); color: var(--fg);
  -webkit-user-select: none; user-select: none;
}
.nt-field-add .nt-mirror { line-height: var(--lh-lead); }
.nt-mirror[hidden] { display: none; }
/* подсветка включается только когда зеркало нарисовано: иначе поле осталось бы с невидимым текстом */
.nt-field.nt-hl > .nt-text, .nt-field.nt-hl > .nt-add-text { color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--fg); }
.nt-field.nt-hl > textarea::placeholder { -webkit-text-fill-color: var(--muted); }
.nm-phone, .nv-phone { color: var(--c-link); }
.nm-dim { color: var(--muted); }
/* оформление в зеркале, пока идёт набор: ширина букв и высота строк те же, что в поле (иначе текст разъехался бы с курсором) — жирное и заголовки обводкой,
   курсив наклоном (своего курсивного начертания у шрифта нет), заголовки того же размера */
.nm-b, .nm-h1, .nm-h2, .nm-big { -webkit-text-stroke-width: 0.03em; -webkit-text-stroke-color: currentColor; }
.nm-h1 .nm-dim, .nm-h2 .nm-dim, .nm-big .nm-dim, .nm-b .nm-dim { -webkit-text-stroke-width: 0; }
.nm-i { font-style: italic; }
.nm-s { text-decoration: line-through; }
.nm-mark { background: color-mix(in srgb,var(--ng-label-color,var(--ng-paper-note)) 38%,transparent); }

/* ---------- оформленный вид в самом редакторе: пока поле не в фокусе, вместо него виден текст с оформлением (105-note.js, класс nt-viewing).
   Поле остаётся на месте прозрачным и без касаний: фокус в него (касание по виду, «Дописать», кнопки) возвращает обычный набор ---------- */
.nt-view { display: none; }
.nt-field.nt-viewing > .nt-view {
  display: block; position: relative; z-index: 1; font-family: var(--font-ui); font-size: var(--fs-lead); line-height: var(--lh-note); color: var(--fg);
  cursor: text; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
.nt-field.nt-viewing > .nt-view * { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.nt-field-add.nt-viewing > .nt-view { line-height: var(--lh-lead); }
#note .nt-field:not(.nt-field-add).nt-viewing > .nt-view { min-height: 240px; }
.nt-field.nt-viewing > .nt-mirror { display: none; }
.nt-field.nt-viewing > textarea { position: absolute; top: 0; left: 0; width: 100%; height: 1px !important; min-height: 0 !important; opacity: 0; pointer-events: none; }

/* ---------- панель форматирования ---------- */
.nt-fmt {
  flex: none; display: flex; gap: var(--sp-6); align-items: center; padding: var(--sp-6) var(--sp-12); overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--dialog-line); background: var(--dialog-glass); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); scrollbar-width: none;
}
.nt-fmt::-webkit-scrollbar { display: none; }
.nt-fmt[hidden] { display: none; }
.nt-fmt button {
  flex: none; min-width: var(--tap); min-height: calc(var(--tap) - var(--sp-4)); padding: 0 var(--sp-12); color: var(--fg); font-size: var(--fs-small); line-height: var(--lh-small); white-space: nowrap;
  border: 1px solid var(--dialog-line); border-radius: var(--r-12); background: var(--dialog-field); box-shadow: inset 0 1px color-mix(in srgb,var(--fg) 20%,transparent);
  touch-action: manipulation;
}
.nt-fmt button:active { background: color-mix(in srgb,var(--ng-label-color,var(--fg)) 24%,transparent); }
.nt-fmt button:focus-visible { outline: 2px solid var(--ng-label-color,var(--fg)); outline-offset: 2px; }

/* ---------- оформленный вид (удержание заметки, 114-notes-shell.js) ---------- */
.ng-peek-text.nv { white-space: normal; }
.nv-p, .nv-h1, .nv-h2, .nv-big, .nv-li, .nv-add { overflow-wrap: anywhere; }
.nv-p { white-space: pre-wrap; min-height: var(--lh-note); }
.nv-gap { height: var(--sp-8); }
.nv-h1 { margin: var(--sp-12) 0 var(--sp-4); font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--fw-bold); letter-spacing: var(--ls-snug); }
.nv-h2 { margin: var(--sp-8) 0 var(--sp-2); font-size: var(--fs-strong); line-height: var(--lh-strong); font-weight: var(--fw-bold); }
.nv-big { font-size: var(--fs-h3); line-height: var(--lh-h3); }
.nv-h1:first-child, .nv-h2:first-child { margin-top: 0; }
.nv-add { margin: var(--sp-8) 0 var(--sp-2); font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--muted); }
.nv-li { display: flex; align-items: flex-start; gap: var(--sp-8); }
.nv-li[data-level="1"] { padding-inline-start: var(--sp-20); }
.nv-li[data-level="2"] { padding-inline-start: calc(var(--sp-20) * 2); }
.nv-li[data-level="3"] { padding-inline-start: calc(var(--sp-20) * 3); }
.nv-li[data-level="4"] { padding-inline-start: calc(var(--sp-20) * 4); }
.nv-bullet { flex: none; min-width: var(--sp-16); text-align: end; color: var(--muted); }
.nv-c { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; }
.nv-box {
  position: relative; flex: none; width: var(--sp-24); height: var(--sp-24); margin-top: var(--sp-2); padding: 0;
  border: 2px solid var(--muted); border-radius: var(--r-8); background: transparent; color: var(--fg);
}
.nv-box::after { content: ""; position: absolute; inset: calc(-1 * var(--sp-10)); }
.nv-box[aria-checked="true"] { border-color: var(--ng-label-color,var(--fg)); background: color-mix(in srgb,var(--ng-label-color,var(--fg)) 36%,transparent); }
.nv-box[aria-checked="true"]::before {
  content: ""; position: absolute; left: var(--sp-6); top: var(--sp-2); width: var(--sp-6); height: var(--sp-12);
  border: solid var(--fg); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.nv-box:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.nv-task[data-checked] .nv-c { color: var(--muted); text-decoration: line-through; }
.nv-hl { color: var(--fg); background: color-mix(in srgb,var(--ng-label-color,var(--ng-paper-note)) 38%,transparent); border-radius: var(--r-8); padding: 0 var(--sp-2); }
.nv-phone { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nv-phone:focus-visible { outline: 2px solid var(--c-link); outline-offset: 2px; border-radius: var(--r-8); }
.nv-h1 strong, .nv-h2 strong { font-weight: inherit; }
/* ссылка в тексте заметки (аудит 18.11, Б14): нажимается и открывает браузер */
.nv-link { color: var(--c-link); text-decoration-line: underline; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
