/* ──────────────────────────────────────────────────────────────────
   Заметки — рабочие столы а-ля Sticky Notes.
   Холст (бесконечный, панорамируется/масштабируется) + списочный режим.
   Стилистика наследует токены приложения (01-tokens.css).
   ────────────────────────────────────────────────────────────────── */
.notes-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}
/* ── Верхняя панель ── */
.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.notes-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}
.notes-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
  max-width: 220px;
  transition: background .15s, color .15s, border-color .15s;
}
.notes-tab:hover {
  background: var(--chip-hover);
  color: var(--text);
}
.notes-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.notes-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notes-tab-edit {
  border: 1px solid var(--accent);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 2px 6px;
  outline: none;
  width: 140px;
}
.notes-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  opacity: .55;
  transition: opacity .12s, background .12s;
}
.notes-tab-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .25);
}
.notes-tab-add {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--text-secondary);
  background: var(--surface2);
  border: 1px dashed var(--border-strong);
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.notes-tab-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.notes-toolbar-spacer { flex: 1 1 auto; }
.notes-add-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notes-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
}
.notes-add-ico { font-size: 14px; line-height: 1; }
.notes-view-switch {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.notes-view-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  color: var(--text-secondary);
  transition: background .15s, color .15s;
}
.notes-view-switch button:hover { color: var(--text); background: var(--chip-hover); }
.notes-view-switch button.active { background: var(--accent); color: #fff; }
/* ── Бесконечный холст ── */
.notes-canvas-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  background-color: var(--bg);
  /* Точечная сетка — «рабочий стол». Перерисовывается JS при зуме/панораме
     через инлайновый background-position/size. */
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.notes-canvas-viewport.panning { cursor: grabbing; }
.notes-canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}
.notes-canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  max-width: calc(100% - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .4s var(--ease);
}
.notes-zoom-ctl {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.notes-zoom-ctl button {
  min-width: 36px;
  height: 32px;
  padding: 0 8px;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 700;
  transition: background .12s, color .12s;
}
.notes-zoom-ctl button:hover { background: var(--chip-hover); color: var(--text); }
.notes-zoom-ctl button#notes-zoom-reset {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
/* ── Стикер (заметка) на холсте ── */
.note-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #2a2a2a;                 /* стикеры всегда светлые → тёмный текст */
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .08);
  will-change: transform;
  /* Лёгкий «бумажный» наклон убираем при перетаскивании через JS-класс. */
  transition: box-shadow .15s var(--ease);
}
.note-card.dragging {
  box-shadow: var(--shadow-xl);
  cursor: grabbing;
  z-index: 99999 !important;
}
.note-card.resizing { box-shadow: var(--shadow-xl); }
.note-card-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 2px;
  background: rgba(0, 0, 0, .06);
  flex-shrink: 0;
}
/* Хват-стикер перемещения */
.note-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 26px;
  color: rgba(0, 0, 0, .35);
  cursor: grab;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background .12s, color .12s;
}
.note-grip:hover { background: rgba(0, 0, 0, .1); color: rgba(0, 0, 0, .65); }
.note-card.dragging .note-grip { cursor: grabbing; }
.note-card--ro .note-grip { cursor: default; opacity: .3; }
.note-card--ro .note-grip:hover { background: transparent; }
/* Бейдж автора на общем столе */
.note-author {
  font-size: 10px;
  font-weight: 700;
  color: rgba(0, 0, 0, .5);
  padding: 2px 10px 0;
  text-transform: uppercase;
  letter-spacing: .03em;
  flex-shrink: 0;
}
/* Меню «⋮» */
.note-menu-pop {
  position: absolute;
  top: 30px;
  right: 6px;
  z-index: 30;
  min-width: 188px;
  padding: 5px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.note-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #2a2a2a;
  text-align: left;
  transition: background .12s;
}
.note-menu-item:hover { background: rgba(0, 0, 0, .07); }
.note-menu-item--danger { color: #b91c1c; }
.note-menu-item--danger:hover { background: rgba(220, 38, 38, .12); }
.note-menu-ico { width: 18px; text-align: center; flex-shrink: 0; }
.note-menu-sep { height: 1px; background: rgba(0, 0, 0, .1); margin: 4px 6px; }
/* Блоки внутри заметки */
.note-block { position: relative; margin-bottom: 8px; }
.note-block:last-child { margin-bottom: 0; }
.note-block-del {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .12);
  color: rgba(0, 0, 0, .55);
  font-size: 13px; line-height: 1;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.note-block:hover .note-block-del { opacity: 1; }
.note-block-del:hover { background: rgba(220, 38, 38, .2); color: #b91c1c; }
.note-block--image:hover .note-block-del { opacity: 1; }
.note-card-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(0, 0, 0, .65);
  border: 0;
  background: transparent;
  outline: none;
  padding: 2px 2px;
  font-family: inherit;
}
.note-card-title::placeholder { color: rgba(0, 0, 0, .3); }
.note-head-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: rgba(0, 0, 0, .5);
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.note-head-btn:hover { background: rgba(0, 0, 0, .12); color: rgba(0, 0, 0, .8); }
.note-head-btn.note-del:hover { background: rgba(220, 38, 38, .18); color: #b91c1c; }
/* Палитра цветов */
.note-color-pop {
  position: absolute;
  top: 30px;
  right: 6px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.note-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, .12);
  cursor: pointer;
  transition: transform .1s var(--ease);
}
.note-swatch:hover { transform: scale(1.12); }
.note-swatch.sel { box-shadow: 0 0 0 2px #2a2a2a; }
.note-card-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
}
/* Текстовый блок */
.note-text-area {
  width: 100%;
  min-height: 22px;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: #2a2a2a;
  font-family: inherit;
  overflow: hidden;
}
.note-text-area::placeholder { color: rgba(0, 0, 0, .35); }
.note-text-area:disabled { color: #2a2a2a; -webkit-text-fill-color: #2a2a2a; opacity: 1; }
/* Форматируемый текст заметки (contenteditable) */
.note-rte {
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.note-rte:focus { outline: none; }
.note-rte:empty:before {
  content: attr(data-ph);
  color: rgba(0, 0, 0, .35);
  pointer-events: none;
}
.note-rte img { max-width: 100%; height: auto; }
/* Панель форматирования текста */
.note-rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-bottom: 5px;
  padding: 3px 4px;
  background: rgba(0, 0, 0, .045);
  border-radius: 6px;
}
.note-rte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #2a2a2a;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.note-rte-btn:hover { background: rgba(0, 0, 0, .1); }
.note-rte-btn .ico { width: 14px; height: 14px; }
.note-rte-sep {
  width: 1px;
  height: 16px;
  margin: 0 3px;
  background: rgba(0, 0, 0, .15);
}
.note-rte-color {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  color: #2a2a2a;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.note-rte-color:hover { background: rgba(0, 0, 0, .1); }
.note-rte-color input[type="color"] {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  height: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.note-rte-size {
  height: 22px;
  border: 1px solid rgba(0, 0, 0, .15);
  border-radius: 4px;
  background: rgba(255, 255, 255, .6);
  color: #2a2a2a;
  font-size: 11px;
  cursor: pointer;
}
/* Картинка-блок */
.note-image-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.note-image-wrap img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}
/* Чек-лист внутри заметки */
.note-checklist { display: flex; flex-direction: column; gap: 3px; }
.note-cl-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 2px 0;
}
.note-cl-check {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 4px;
  border: 1.5px solid rgba(0, 0, 0, .35);
  background: rgba(255, 255, 255, .5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.note-cl-check.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.note-cl-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  color: #2a2a2a;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  word-break: break-word;
  padding: 0;
}
.note-cl-item.done .note-cl-text {
  text-decoration: line-through;
  color: rgba(0, 0, 0, .4);
}
.note-cl-del {
  opacity: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: rgba(0, 0, 0, .4);
  font-size: 13px;
  flex-shrink: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.note-cl-item:hover .note-cl-del { opacity: 1; }
.note-cl-del:hover { background: rgba(220, 38, 38, .15); color: #b91c1c; }
.note-cl-add {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(0, 0, 0, .5);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px;
  border-radius: 4px;
  align-self: flex-start;
}
.note-cl-add:hover { background: rgba(0, 0, 0, .08); color: rgba(0, 0, 0, .8); }
/* Ручка ресайза */
.note-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 5;
}
.note-resize::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(0, 0, 0, .35);
  border-bottom: 2px solid rgba(0, 0, 0, .35);
}
/* ── Списочный режим ── */
.notes-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 32px;
  background: var(--bg);
}
.notes-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notes-list-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.notes-list-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.notes-list-kind {
  font-size: 18px;
  line-height: 1.2;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}
.notes-list-main { flex: 1; min-width: 0; }
.notes-list-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  word-break: break-word;
}
.notes-list-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notes-list-snippet img { max-width: 120px; max-height: 80px; border-radius: 4px; }
.notes-list-cl {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notes-list-cl-item {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 6px;
  align-items: center;
}
.notes-list-cl-item.done { text-decoration: line-through; color: var(--text-muted); }
.notes-list-actions { display: flex; gap: 4px; flex-shrink: 0; }
.notes-list-locate, .notes-list-del {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background .12s, color .12s;
}
.notes-list-locate:hover { background: var(--chip-bg); color: var(--accent); }
.notes-list-del:hover { background: var(--danger-soft); color: var(--danger); }
.notes-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 60px 20px;
}
.note-cl-text:disabled {
  color: #2a2a2a; -webkit-text-fill-color: #2a2a2a; opacity: 1;
}
.note-card-title:disabled {
  color: rgba(0, 0, 0, .65); -webkit-text-fill-color: rgba(0, 0, 0, .65); opacity: 1;
}
/* Чужая (read-only) заметка на общем столе */
.note-card--ro { border-style: dashed; }
.note-card--ro .note-cl-check { cursor: default; }
/* Вкладка общего стола */
.notes-tab--shared.active { background: #6d28d9; border-color: #6d28d9; }
.notes-tab-ico { font-size: 12px; line-height: 1; flex-shrink: 0; }
body:not(.theme-dark) .notes-tab--shared:not(.active) {
  background: #f3effe; border-color: #ddd2f5; color: #6d28d9;
}
.notes-list-author { color: var(--text-muted); font-weight: 500; font-size: 12px; }
/* Инструменты поверх картинки (просмотр/удалить) */
.note-image-wrap { position: relative; }
.note-image-tools {
  position: absolute;
  top: 4px; right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.note-image-wrap:hover .note-image-tools { opacity: 1; }
.note-img-tool {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  transition: background .12s;
}
.note-img-tool:hover { background: rgba(0, 0, 0, .78); }
.note-img-tool--danger:hover { background: #b91c1c; }
/* Лайтбокс просмотра картинки */
.notes-lightbox {
  position: fixed;
  inset: 0;
  z-index: 11000;
  background: rgba(0, 0, 0, .85);
  display: flex;
  flex-direction: column;
}
.notes-lightbox-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  flex-shrink: 0;
}
.notes-lightbox-bar button {
  min-width: 40px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background .12s;
}
.notes-lightbox-bar button:hover { background: rgba(255, 255, 255, .25); }
.notes-lightbox-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}
.notes-lightbox-stage.panning { cursor: grabbing; }
.notes-lightbox-stage img {
  max-width: 92vw;
  max-height: 80vh;
  user-select: none;
  transform-origin: center center;
  will-change: transform;
}
/* Кнопка создания общего стола */
.notes-tab-add--shared {
  position: relative;
  width: auto;
  padding: 0 8px;
  gap: 2px;
  display: inline-flex;
  align-items: center;
  color: #6d28d9;
  border-color: #c9b8f0;
}
.notes-tab-add--shared:hover {
  color: #fff;
  background: #6d28d9;
  border-color: #6d28d9;
}
.notes-add-shared-plus { font-size: 13px; font-weight: 700; line-height: 1; }
/* ── Светлая тема ── */
body:not(.theme-dark) .notes-view {
  --bg:             #f4f1ea;
  --surface:        #ffffff;
  --surface2:       #f3f4f6;
  --text:           #1f2937;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         #d8dde6;
  --border-strong:  #b4bcc9;
  --chip-hover:     #e2e8f0;
  --input-bg:       #ffffff;
  background: var(--bg);
  color: var(--text);
}
body:not(.theme-dark) .notes-canvas-viewport {
  background-image: radial-gradient(circle, #d2cdc2 1px, transparent 1px);
}
