/* EveryIdea — волна 3: Корзина / Архив / Мультивыбор / Напоминания.
   Свои блоки: bin-*, sel-*, selection-bar, remind-*, toast-actionable,
   nav-count, cal-remind-mark. Только var()-токены тем — работает во всех
   четырёх темах (Бумага/Оникс/AMOLED/Аврора) без отдельных правил.
   Загружается ПОСЛЕДНИМ в index.html — переопределения base.css ниже осознанны. */

/* --- счётчики навигации (Архив/Корзина) --- */
.nav-count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--hint);
  font-size: var(--font-xs);
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}
.nav-btn.active .nav-count {
  background: var(--accent-soft);
  color: var(--accent-strong); /* 11px текст на accent-soft: тёмные темы <4.5 → strong */
}
/* .sidebar уже flex-column (app.css) — прижимаем блок к низу */
.sidebar-bottom {
  margin-top: auto;
  padding-top: var(--s2);
  border-top: 1px solid var(--separator);
}

/* --- разделы «Архив»/«Корзина» --- */
.bin-view {
  display: none;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s4);
  gap: var(--s3);
}
.bin-view.active-view {
  display: flex;
}
.bin-view .pane-toolbar {
  padding: 0;
  border: 0;
  background: none;
}
.bin-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.bin-view .empty-state {
  max-width: 720px;
  margin: 0 auto;
}
.bin-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.bin-row-main {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-control);
}@media (hover: hover) and (pointer: fine){
  .bin-row-main:hover { background: var(--fill); }
}
.bin-row-main:active { background: var(--fill); }
.bin-row-main .icon {
  width: 22px;
  height: 22px;
  color: var(--hint);
  flex: none;
}
.bin-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.bin-row-title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bin-row-sub {
  font-size: 12px;
  color: var(--hint);
}
.bin-row-actions {
  display: flex;
  gap: var(--s2);
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bin-row-actions .icon {
  width: 15px;
  height: 15px;
}

/* --- мультивыбор: чекбоксы строк --- */
.sel-check {
  display: none;
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--hint);
  align-self: flex-start;
  margin-top: 2px;
}
.sel-check .icon {
  width: 22px;
  height: 22px;
}
.selecting .sel-check {
  display: block;
}
.selecting .note-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.selecting .note-card.selected .sel-check {
  color: var(--accent);
}
/* кнопки «☑» и «Выбрать все» в шапке списка */
.sel-all-btn {
  display: none;
}
.selecting .sel-all-btn {
  display: inline-flex;
}
.selecting .sel-toggle-btn {
  color: var(--accent);
  background: var(--accent-soft);
}

/* --- нижняя панель действий (fixed, pill, thumb-zone) --- */
.selection-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--s4) + var(--safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 60;
}
.selection-bar.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
/* --- тост с кнопкой действия («Отменить» для корзины) --- */
/* Все тосты интерактивны (волна ui-audit): error/action — липкие (закрытие
   кнопкой ✕), info/success — пауза таймера по ховеру и dismiss по клику. */
.toast-actionable {
  pointer-events: auto; /* base.css глушит клики на тостах — здесь они нужны */
  cursor: default;
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.toast-close {
  flex: none;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--r-sm);
  color: inherit;
  font-size: 13px;
  line-height: 1;
  opacity: 0.8;
  cursor: pointer;
}@media (pointer: coarse){
  .toast-close { min-width: 44px; min-height: 44px; }
}@media (hover: hover) and (pointer: fine){
  .toast-close:hover { opacity: 1; background: var(--fill); }
}
.toast-action-btn {
  flex: none;
  min-height: 32px;
  padding: var(--s1) var(--s3);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-strong); /* accent на accent-soft в AMOLED = 2.46:1 → strong */
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}@media (hover: hover) and (pointer: fine){
  .toast-action-btn:hover {
    background: var(--accent);
    color: var(--accent-contrast);
  }
}
.toast-action-btn:active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* --- центр напоминаний: bell + бейдж + панель --- */
.remind-root {
  position: fixed;
  top: calc(var(--s3) + var(--safe-area-inset-top));
  right: var(--s4);
  z-index: 70;
}
.remind-bell {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--hint);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}@media (hover: hover) and (pointer: fine){
  .remind-bell:hover {
    color: var(--accent);
  }
}
.remind-bell.open,
.remind-bell.has-badge {
  color: var(--accent);
}
.remind-bell .icon {
  width: 21px;
  height: 21px;
}
.remind-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--destructive);
  /* цвет текста на заливке — темозависимый токен (--on-destructive):
     в «Бумаге» белый (4.83:1), в тёмных темах тёмный (светлый #ff7b6e и
     подобные дают с белым ~3.3:1 — ниже AA). Раньше здесь висел список
     конкретных тёмных тем — он удалён: токен сам знает ответ. */
  color: var(--on-destructive, #fff);
  font-size: var(--font-xs);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.remind-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: 70dvh;
  overflow-y: auto;
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.remind-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}
.remind-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.remind-section-label {
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
  padding: var(--s1) var(--s1) 0;
}
.remind-label-overdue {
  color: var(--destructive);
}
.remind-empty {
  padding: var(--s2);
}
.remind-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  border-radius: var(--r-control);
  background: var(--surface-2);
}
.remind-overdue {
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, transparent);
}
.remind-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.remind-row-main .icon {
  width: 18px;
  height: 18px;
  color: var(--hint);
  flex: none;
}
.remind-overdue .remind-row-main .icon {
  color: var(--destructive);
}
.remind-row-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.remind-row-time {
  flex: none;
  font-size: var(--font-xs);
  color: var(--hint);
}
.remind-overdue .remind-row-time {
  color: var(--destructive);
  font-weight: 600;
}
.remind-clear {
  flex: none;
}

/* --- диалог напоминания: пресеты --- */
.remind-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}
.remind-actions {
  flex-wrap: wrap;
}
.remind-actions-spacer {
  flex: 1;
}

/* --- флажок напоминания на карточках и в тулбаре редактора --- */
.remind-flag {
  width: 14px;
  height: 14px;
  color: var(--warning);
  flex: none;
}
.remind-doc-btn.remind-on {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
}

/* --- календарь: маркер напоминания (ромб, не путать с точками документов) --- */
.cal-remind-mark {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 12px;
  line-height: 1;
  color: var(--warning);
}
.cal-cell {
  position: relative;
}
.chip-remind {
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip-remind .icon {
  width: 12px;
  height: 12px;
}/* --- мобила (≤600px): thumb-zone, нижняя навигация из 4 пунктов (волна 5b) --- */
@media (max-width: 600px){
  .selection-bar {
    bottom: var(--bottom-ui); /* над постоянным нижним таб-баром */
    width: calc(100vw - 24px);
    max-width: none;
    border-radius: 22px; /* при переносе pill-яйцо выглядит плохо — карточка */
    flex-wrap: nowrap;
    justify-content: stretch;
  }
  .remind-root {
    top: calc(var(--s2) + var(--safe-area-inset-top));
    right: var(--s3);
  }
  .remind-panel {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: var(--bottom-ui);
    width: auto;
    max-height: 55dvh;
  }
  /* Нижняя зона: таб-бар постоянный (4 вкладки + ☰), архив/корзина — в ☰-меню
     (main.js → openActionsSheet); строки архива переносятся на мобиле. */
  .bin-row {
    flex-wrap: wrap;
  }
  .bin-row-actions {
    width: 100%;
  }
  .bin-row-actions .btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
  }
}

/* --- заметки: split-view убран (волна 3) — всегда одна панель --- */
/* Переопределяем toolbar.css (lists.css подключён последним). */
.note-editor-pane.mode-preview .md-edit-wrap { display: none; }
.note-editor-pane.mode-edit .editor-stack > .md-preview { display: none; }
.note-editor-pane .md-preview { border-left: none; }
/* segmented «Текст/Просмотр» заменён явным значком-переключателем в шапке */
.mode-toggle-btn { flex: none; }/* --- reduced motion --- */
@media (prefers-reduced-motion: reduce){
  :root:not([data-motion-force='1']) .selection-bar {
    transition: none;
  }
}

/* --- чипы вложений в заметках (FILES-CONTRACT, интеграция: заметка) --- */
/* Ряд чипов под мета-строкой редактора — виден и в режиме превью, и в редакторе. */
.attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: 0 var(--s6) var(--s2);
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 3px 4px 3px var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--separator);
  border-radius: var(--r-pill);
}
.attach-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.attach-chip-main .icon {
  width: 14px;
  height: 14px;
  color: var(--hint);
  flex: none;
}
.attach-chip-name {
  font-size: 12px;
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip-size {
  font-size: var(--font-xs);
  color: var(--hint);
  flex: none;
}
.attach-chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--hint);
  cursor: pointer;
  flex: none;
}
.attach-chip-btn .icon {
  width: 13px;
  height: 13px;
}@media (hover: hover) and (pointer: fine){
  .attach-chip-btn:hover {
    background: var(--fill);
    color: var(--text);
  }
  .attach-chip-btn.danger:hover {
    background: color-mix(in srgb, var(--destructive) 12%, transparent);
    color: var(--destructive);
  }
}
.attach-chip-broken .attach-chip-main {
  color: var(--hint);
  cursor: default;
}
.attach-chip-broken .attach-chip-name {
  font-style: italic;
}
/* подсветка редактора при drag&drop файла */
.note-editor-pane.attach-dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}@media (max-width: 600px){
  .attach-chips { padding: 0 var(--s4) var(--s2); }
  .attach-chip-btn { width: 32px; height: 32px; } /* thumb-zone */
}

/* --- папки: секции в списках + диалог выбора папки --- */
.folder-sec {
  display: flex;
  align-items: center;
  gap: var(--s1);
  margin-top: var(--s2);
  border-radius: var(--r-control);
}
.folder-sec-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: var(--s1) var(--s2);
  background: none;
  border: 0;
  border-radius: var(--r-control);
  color: var(--hint);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: left;
}@media (hover: hover) and (pointer: fine){
  .folder-sec-main:hover {
    background: var(--fill);
    color: var(--text);
  }
}
.folder-sec-main:active {
  background: var(--fill);
  color: var(--text);
}
.folder-sec-caret {
  width: 14px;
  flex: none;
  font-size: var(--font-xs);
}
.folder-sec-icon {
  flex: none;
  font-size: 13px;
}
.folder-sec-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-sec-count {
  flex: none;
  margin-left: auto;
  font-weight: 600;
  color: var(--hint);
}
.folder-sec-del {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--hint);
  font-size: var(--font-xs);
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease;
}@media (hover: hover) and (pointer: fine){
  .folder-sec:hover .folder-sec-del,
  .folder-sec-del:focus-visible {
    opacity: 1;
  }
  .folder-sec-del:hover {
    color: var(--destructive);
    background: color-mix(in srgb, var(--destructive) 12%, transparent);
  }
}
.folder-sec-del:focus-visible {
  opacity: 1;
}
.folder-sec-del:active {
  color: var(--destructive);
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
}@media (max-width: 600px){
  .folder-sec-del { opacity: 1; width: 36px; height: 36px; } /* hover нет — всегда видна */
  .folder-sec-main { min-height: 44px; } /* thumb-zone */
}

/* диалог выбора папки */
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 40dvh;
  overflow-y: auto;
  margin-bottom: var(--s3);
}
.folder-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 40px;
  padding: var(--s2) var(--s3);
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}@media (hover: hover) and (pointer: fine){
  .folder-row:hover { background: var(--fill); }
}
.folder-row:active { background: var(--fill); }
.folder-row.current { background: var(--accent-soft); color: var(--accent); }
.folder-row-indent { flex: none; }
.folder-row-icon { flex: none; }
.folder-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-row-mark {
  flex: none;
  font-size: var(--font-xs);
  color: var(--hint);
}
.folder-new-row {
  display: flex;
  gap: var(--s2);
}
.folder-new-row .input { flex: 1; }

/* choiceDialog: варианты с подсказками */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.choice-list .btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}
.choice-hint {
  font-size: var(--font-xs);
  font-weight: 400;
  opacity: 0.75;
}

/* --- контекстное меню карточки (bottom sheet / dropdown, Obsidian-стиль) --- */
.ctx-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.25);
  /* Скрим входит синхронно со шторкой: 150ms swing (эталон Obsidian Mobile
     1.14.4 — фон меню 150ms, motion.md:44-47). Масштабируется ползунком. */
  animation: ctx-scrim-in calc(var(--dur-sheet, 150ms) * var(--motion-scale, 1)) var(--ease-swing, cubic-bezier(0, 0.55, 0.45, 1)) backwards;
}
@keyframes ctx-scrim-in { from { opacity: 0; } }
@keyframes ctx-scrim-out { to { opacity: 0; } }
/* Выход поповера (десктоп): мягкий уход вверх, симметрично входу -4px.
   Шторка выходит своим sheet-exit (ниже). */
@keyframes ctx-pop-out { to { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.ctx-root.closing {
  animation: ctx-scrim-out calc(var(--dur-fast, 140ms) * var(--motion-scale, 1)) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) both;
  pointer-events: none; /* скрим не ловит тапы, пока истаивает */
}
.ctx-root.ctx-sheet {
  /* скрим шторки — плотнее (эталон: −27…30% яркости → 0.55) */
  background: var(--scrim-strong);
}
.ctx-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.ctx-sheet {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  flex-direction: column;
}
.ctx-sheet .ctx-card {
  /* edge-to-edge: единая поверхность шторки, скруглены только верхние углы.
     Низ — над постоянным таб-баром (--tabbar-h = 0 на десктопе): шторка
     не перекрывает навигацию, бар остаётся виден и доступен. */
  margin: 0 0 calc(var(--tabbar-h) + var(--safe-area-inset-bottom));
  gap: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--bg-secondary);
  /* Волна 17 (Obsidian structures §1): меню — max-height 60vh эталона
     (было 88dvh волны 8); длинные меню скроллятся, при скролле —
     fade 48px сверху (ctx-scroll-fade ниже, progressive enhancement). */
  max-height: 60dvh;
  overflow-y: auto;
  /* Вход шторки — 150ms swing (эталон Obsidian Mobile 1.14.4, motion.md §2:
     cubic-bezier(0, 0.55, 0.45, 1) = токен --ease-swing). Длительность
     масштабируется --motion-scale. */
  animation: sheet-enter calc(var(--dur-sheet, 150ms) * var(--motion-scale, 1)) var(--ease-swing) backwards;
}
/* Волна 20: пока шторку ведёт палец — переходы на ней и её строках
   отключены. Иначе «резинка»: CSS-transition догоняет палец с задержкой,
   и жест дёргается на старте/финише. Класс ставит modal.js
   (attachSheetDrag) и снимает по отпусканию. */
body.sheet-dragging .ctx-sheet .ctx-card,
body.sheet-dragging .ctx-sheet .ctx-card *,
body.sheet-dragging .ctx-item {
  transition: none !important;
}
body.sheet-dragging .ctx-sheet .ctx-card { will-change: transform; }
@keyframes ctx-sheet-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
/* Fade 48px сверху при скролле меню (Obsidian --menu-scroll-mask,
   structures §1): маска зафиксирована в рамке карточки, контент уходит
   под неё. Scroll-driven animation — маска только когда меню проскроллено
   (наверху — from, без маски); без поддержки scroll() — маски нет вовсе
   (контент просто скроллится, как раньше). Enter-анимация сохранена
   первым элементом списка (auto-таймлайн). */
@keyframes ctx-scroll-fade {
  from { mask-image: linear-gradient(to bottom, #000 0, #000 48px); }
  to { mask-image: linear-gradient(to bottom, transparent 0, #000 48px); }
}@supports (animation-timeline: scroll(self block)){
  .ctx-sheet .ctx-card {
    animation:
      sheet-enter calc(var(--dur-sheet, 150ms) * var(--motion-scale, 1)) var(--ease-swing) backwards,
      ctx-scroll-fade linear both;
    animation-timeline: auto, scroll(self block);
    animation-range: normal, 0px 48px;
  }
}
/* Drag-to-dismiss (modal.js attachSheetDrag): transition для inline-transform
   жеста. Enter-анимации не конфликтуют — другой канал (animation); во время
   драга JS ставит transition:none инлайн. При выключенных анимациях длительность
   нулится blanket-гейтом → dismiss мгновенный, без паузы. */
.ctx-sheet .ctx-card, .sel3-card, .remind-panel {
  transition: transform calc(var(--duration-fast, 150ms) * var(--motion-scale, 1)) var(--ease-out);
}
/* Exit: modal.js вешает .closing на root и карточку, ждёт animationend/
   страховочный таймер и только потом удаляет узел. Длительность — 140ms
   (эталон: выход шторки 100·доля мс, motion.md:44-47); --motion-scale
   масштабирует, blanket-гейт обнуляет при reduced-motion. */
.ctx-sheet .ctx-card.closing {
  animation: sheet-exit calc(var(--duration-fast, 140ms) * var(--motion-scale, 1)) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) both;
  pointer-events: none;
}
.ctx-pop .ctx-card.closing {
  animation: ctx-pop-out calc(var(--duration-fast, 140ms) * var(--motion-scale, 1)) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) both;
  pointer-events: none;
}
.ctx-handle {
  display: none;
}
.ctx-sheet .ctx-handle {
  display: block;
  width: var(--sheet-handle-w);
  /* волна 17: border-box съедал полоску (height 4px − padding 12px →
     content-box 0 — ручка не рисовалась). Полоска = токен (4px эталона),
     тач-зона = +12px паддингами (background-clip: content-box). */
  height: calc(var(--sheet-handle-h) + 12px);
  border-radius: var(--r-pill);
  background: var(--separator);
  margin: 4px auto 2px;
  flex: none;
  align-self: center;
  /* жест закрытия за ручку не отдавать браузерному скроллу (pointercancel);
     контент шторки скроллится нативно, ручка — чистый drag (modal.js) */
  touch-action: none;
  /* тач-зона ручки шире визуальной полоски */
  padding: 6px 0;
  background-clip: content-box;
}
.ctx-pop {
  /* лёгкий scrim и на десктопе: отделяет меню от карточек позади */
  background: rgba(0, 0, 0, 0.18);
}
.ctx-pop .ctx-card {
  position: fixed; /* координаты — из JS (у курсора/кнопки) */
  min-width: 240px;
  max-width: 320px;
  max-height: 70dvh;
  overflow-y: auto;
  animation: ctx-pop-in 140ms ease;
}
@keyframes ctx-pop-in {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.ctx-title {
  padding: var(--s2) var(--s4) 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* группы — отдельные pill-карточки (как на референсе): явный «этаж выше» —
   читаемый бордер + подъёмная тень, на светлой теме не сливаются с карточками */
.ctx-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  /* flex-колонка карточки + max-height: без flex:none группа сжималась и
     КЛИПИЛА пункты (overflow:hidden) вместо скролла шторки — длинная
     «Структура» обрезалась без возможности долистать */
  flex: none;
}
/* в шторке — группы-карточки на единой поверхности шторки (бордер/лифт
   не нужны — фон шторки и групп разделяет цвет). Волна 17 (Obsidian
   structures §1): радиус группы 24px (--r-xl), зазор между группами 8px,
   боковые поля 16px (padding menu-scroll эталона 8px 16px). Группы врезаны
   на 16px от края шторки — углы не касаются дуги шторки, концентричность
   не нарушается. */
.ctx-sheet .ctx-group {
  margin: 0 var(--s4) var(--s2);
  border: 0;
  border-radius: var(--r-xl);
  box-shadow: none;
  background: var(--surface-2);
}
/* danger-группа — отдельная карточка в самом низу (Obsidian §2), отбита
   hairline-разделителем сверху */
.ctx-sheet .ctx-group-danger {
  margin-top: 0;
  box-shadow: inset 0 1px 0 var(--separator);
  border-radius: var(--r-card); /* поверх inset-тени сохранить скругление */
}
/* иконка danger-пункта — тоже красная */
.ctx-item.danger .ctx-item-icon { color: var(--destructive); }
/* в шторке: строка 52px (токен), иконка 19px, зазор иконка→текст 21 */
.ctx-sheet .ctx-item { gap: 21px; }
.ctx-sheet .ctx-item-icon .icon { width: 19px; height: 19px; }
/* нижнее поле карточки шторки — 8px зазор последней группы (спека §1:
   padding menu-scroll 8px; safe-area — через margin карточки выше) */
.ctx-sheet .ctx-card { padding: 8px 0 0; }
/* Строка меню — модель Obsidian (structures §1): padding 12px 16px,
   font 15px; min-height 52px (--row-ctx-mobile) держит тач-таргет. */
.ctx-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: var(--row-ctx-mobile); /* тач-строка меню */
  padding: var(--s3) var(--s4);
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--font-lg);
  text-align: left;
  cursor: pointer;
  position: relative; /* якорь разделителя ::after */
}
/* Разделители-линии 1px ВНУТРИ группы — инсет 16px с обеих сторон
   (Obsidian structures §1: ::after, left:16px, width:100%−32px);
   hairline не бьёт в край карточки, hover-фон строки остаётся полной ширины. */
.ctx-group .ctx-item + .ctx-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: var(--s4);
  right: var(--s4);
  height: 1px;
  background: var(--separator);
  pointer-events: none;
}@media (hover: hover) and (pointer: fine){
  .ctx-item:hover { background: var(--fill); }
}
.ctx-item:not([data-no-press]):active {
  background: var(--accent-soft);
  /* единый press-feedback: scale 0.97, 100ms ease-out (эталон Obsidian) */
  transform: scale(0.97);
}
/* transition объявлен отдельно — :active выше по каскаду, но transition
   должен быть на базовом состоянии, чтобы отработать и при отпускании */
.ctx-item {
  transition: transform calc(100ms * var(--motion-scale, 1)) var(--ease-out),
    background-color calc(100ms * var(--motion-scale, 1)) var(--ease-out);
}
.ctx-item.danger { color: var(--destructive); }
/* Недоступный пункт меню (например «переместить строку вверх» у первой
   строки) — приглушён, по нему нельзя попасть. */
.ctx-item:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.ctx-item-icon {
  width: 20px;
  flex: none;
  display: inline-flex;
  color: var(--hint);
}
.ctx-item-icon .icon { width: 18px; height: 18px; }
.ctx-item-label { flex: 1; min-width: 0; }
.ctx-item-hint {
  flex: none;
  font-size: var(--font-xs);
  color: var(--hint);
}

/* ⋮-кнопка на карточке (десктоп — по hover, тач — всегда видна).
   Визуал 28px, ХИТ-ЗОНА 44×44 (WCAG 2.5.8 / эталон Obsidian: 44px) —
   расширена псевдоэлементом ::after на 8px в каждую сторону. */
.card-menu-btn {
  flex: none;
  position: relative;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--hint);
  font-size: var(--font-lg);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, transform 120ms ease-out, background-color 120ms ease;
}
.card-menu-btn::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--r-pill);
}@media (hover: hover) and (pointer: fine){
  .note-card:hover .card-menu-btn,
  .card-menu-btn:focus-visible {
    opacity: 1;
  }
  .card-menu-btn:hover {
    background: var(--fill);
    color: var(--text);
  }
}/* Тач-указатель: hover не существует — действие видно всегда. */
@media (pointer: coarse){
  .card-menu-btn { opacity: 1; }
}
.card-menu-btn:focus-visible {
  opacity: 1;
}
.card-menu-btn:active {
  background: var(--fill);
  color: var(--text);
  transform: scale(0.97);
}
.selecting .card-menu-btn { display: none; }/* в режиме выбора не мешает */
@media (max-width: 600px){
  .card-menu-btn { opacity: 1; width: 36px; height: 36px; position: relative; }
  /* расширение hit-area 36→44px (паттерн .tool-btn::after) без изменения визуала */
  .card-menu-btn::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; }
}@media (prefers-reduced-motion: reduce){
  :root:not([data-motion-force='1']) .ctx-sheet .ctx-card,
  :root:not([data-motion-force='1']) .ctx-pop .ctx-card { animation: none; }
  :root:not([data-motion-force='1']) .card-menu-btn,
  :root:not([data-motion-force='1']) .folder-sec-del,
  :root:not([data-motion-force='1']) .ctx-item { transition: none; }
}

/* Чип даты на карточке заметки (базовое правило — toolbar.css .note-day-chip;
   там трогать нельзя, переопределяем здесь): визуал ~54×18.5px остаётся,
   хит-зона расширяется ::after до ≥44×24 (18.5+2×13=44.5). overflow:visible
   обязателен: у .chip overflow:hidden клиппал бы ::after до размеров чипа. */
.note-day-chip { position: relative; overflow: visible; }
.note-day-chip::after { content: ''; position: absolute; inset: -13px -4px; }

/* --- тулбар доски: действия движка перенесены в тулбар (интеграция) --- */
/* engine-owned overlay-кнопки на канвасе скрыты — их роль у кнопок тулбара
   (.board-trash-panel остаётся: открывается из тулбара через engine API). */
.board-canvas-host > .board-file-btn,
.board-canvas-host > .board-trash-btn,
.board-canvas-host > .board-eye-btn {
  display: none;
}
/* счётчик корзины доски на кнопке тулбара */
.board-trash-tool {
  position: relative;
}
.board-trash-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--destructive);
  color: #fff;
  font-size: var(--font-xs);
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* --- панель мультивыбора v2: компактная pill + «Диапазон» (переопределяет блок выше) --- */
.selection-bar {
  width: auto;
  max-width: calc(100vw - 24px);
  border-radius: var(--r-pill);
  padding: 6px 10px;
  gap: 2px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto; /* 360px: горизонтальный скролл, если не влезло */
  scrollbar-width: none;
}
.selection-bar::-webkit-scrollbar { display: none; }@media (max-width: 600px){
  .selection-bar {
    width: auto;
    max-width: calc(100vw - 24px);
    bottom: var(--bottom-ui);
  }
}/* --- шапка списка: поиск читаем, вторичные контролы переносятся --- */
.boards-list-pane .pane-toolbar{
  flex-wrap: wrap; /* не влезло — вторая строка, поиск не сжимается ниже min-width */
  row-gap: var(--s1);
}
.sel-all-btn .icon { width: 18px; height: 18px; }

/* --- панель мультивыбора v3: язык контекстного меню (ctx-*) ---
   Мобила: нижняя шторка с ручкой; десктоп: компактная панель bottom-center.
   НЕ модальная: root pointer-events:none — карточки списка тапабельны. */
.selection-bar.sel3 {
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: auto;
  max-width: none;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
  gap: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  pointer-events: none !important; /* тапы проходят сквозь корень к списку */
  z-index: 70;
}
.sel3-card {
  /* pointer-events только у ОТКРЫТОЙ панели: панель скрывается opacity:0
     (базовый .selection-bar), а opacity не отключает hit-testing — без этого
     невидимая карточка съедала тапы внизу экрана (FAB, drawer-fab). */
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: calc(100vw - 16px);
  max-width: 420px;
  margin: 0 var(--s2) var(--bottom-ui); /* над единственной нижней панелью */
  max-height: 60dvh;
  overflow-y: auto;
  animation: ctx-sheet-in 200ms ease;
  touch-action: pan-y;
}
.selection-bar.open .sel3-card { pointer-events: auto; }
/* Закрытая панель не должна участвовать ни в hit-test, ни в замерах
   переполнения: opacity:0 оставляет её в раскладке. */
.selection-bar.sel3:not(.open) { visibility: hidden; }
.sel3-card .ctx-handle {
  display: block;
  width: var(--sheet-handle-w);
  /* волна 17: та же геометрия, что у ручки шторки — полоска 4px (токен),
     тач-зона +12px паддингами */
  height: calc(var(--sheet-handle-h) + 12px);
  border-radius: var(--r-pill);
  background: var(--separator);
  margin: 4px auto 0;
  flex: none;
  align-self: center;
  padding: 6px 0;
  background-clip: content-box;
}
.sel3-title {
  text-align: center;
  padding: var(--s2) var(--s4) 0;
}
.sel3-item:disabled {
  opacity: 0.38;
  cursor: default;
}@media (hover: hover) and (pointer: fine){
  .sel3-item:disabled:hover { background: none; }
}
.sel3-item.danger .ctx-item-icon { color: var(--destructive); }
.sel3-item.active { background: var(--accent-soft); }
/* label — текст: на accent-soft --accent давал <4.5 (AMOLED 2.46) → accent-strong;
   иконка остаётся --accent (для графики норма 3:1 проходит) */
.sel3-item.active .ctx-item-label { color: var(--accent-strong); }
.sel3-item.active .ctx-item-icon { color: var(--accent); }

/* v3: заголовок шторки — плавающая pill-подложка (без scrim текст терялся) */
.sel3-title {
  align-self: center;
  margin: 0;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
}
.sel3-card > .ctx-handle {
  margin-top: 0;
}/* v4м: мобила ≤600px — ряд ИКОНОК без обрезки подписей (Obsidian):
   [× Закрыть] [N] [⧉ Все] [🗄 В архив] [🗑 Удалить].
   Подписи и «Выбрано:» остаются в DOM/aria (font-size:0 — innerText харнесса
   и скринридер их видят, а на экране ни текста, ни обрезки нет). */
@media (max-width: 600px){
  .selection-bar.sel3 { align-items: flex-end; }
  .sel3-card {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: auto;
    max-width: calc(100vw - 16px);
    max-height: none;
    overflow: visible;
    padding: 4px 8px;
    margin: 0 auto var(--bottom-ui);
    background: var(--surface);
    border: 1px solid var(--separator);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-lift);
  }
  .sel3-card .ctx-handle { display: none; }
  .sel3-card .ctx-group { display: contents; }
  /* Порядок Obsidian: закрыть · счётчик · все · в архив · удалить. */
  .sel-cancel { order: 0; }
  .sel3-card .sel3-title { order: 1; }
  .sel-all { order: 2; }
  .sel-archive { order: 3; }
  .sel-trash { order: 4; }
  /* «Диапазон» — десктопный жест, на телефоне панель из иконок без него. */
  .sel3-card .sel-range-btn { display: none; }
  .sel3-card .sel3-title {
    position: static;
    transform: none;
    pointer-events: none;
    flex: 0 0 auto;
    padding: 0 8px;
    background: none;
    border: 0;
    box-shadow: none;
    font-size: 0; /* «Выбрано:» не рисуем — виден только счётчик */
    line-height: 1;
  }
  .sel3-card .sel3-title span { font-size: 15px; font-weight: 600; color: var(--text); }
  .sel3-card .sel3-item {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: var(--r-pill);
  }
  /* Подпись не рисуется и не обрезается (scrollWidth == clientWidth == 0),
     но остаётся в innerText — так её находит тач-харнесс. */
  .sel3-card .sel3-item .ctx-item-label { font-size: 0; }
  .sel3-card .sel3-item .ctx-item-icon .icon,
  .sel3-card .sel3-item .ctx-item-icon svg { width: 20px; height: 20px; }
}

/* v4 десктоп/планшет (≥601px): горизонтальная pill-панель в один ряд,
   без скрима и без вертикальной стопки (шторка — только мобила ≤600px) */
@media (min-width: 601px){
  .sel3-card {
    flex-direction: row;
    align-items: center;
    width: auto;
    max-width: calc(100vw - 32px);
    max-height: none;
    margin: 0 0 var(--s4);
    padding: 6px;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-lift);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    animation: ctx-pop-in 140ms ease;
  }
  .sel3-card .ctx-handle { display: none; }
  .sel3-title {
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0 10px;
    flex: none;
    white-space: nowrap;
  }
  .sel3-card .ctx-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  .sel3-card .ctx-group + .ctx-group {
    border-left: 1px solid var(--separator);
    padding-left: 4px;
    margin-left: 2px;
  }
  .sel3-card .ctx-item {
    min-height: var(--row-ctx-desktop);
    min-width: 0;
    width: auto;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    white-space: nowrap;
    flex: none;
  }
  .sel3-card .ctx-item + .ctx-item { border-top: 0; }
  /* разделитель — ::after-линия (волна 17): в горизонтальной pill-строке
     десктопа не нужен */
  .sel3-card .ctx-item + .ctx-item::after { content: none; }
}

/* --- папки: SVG-иконка (вместо emoji) + аккуратная строка на мобиле --- */
.folder-sec-icon { display: inline-flex; }
.folder-sec-icon .icon { width: 14px; height: 14px; }
.folder-row-icon { display: inline-flex; color: var(--hint); }
.folder-row-icon .icon { width: 16px; height: 16px; }
.folder-row.current .folder-row-icon { color: var(--accent); }@media (max-width: 600px){
  /* строка секции: [caret][папка][название …][счётчик][+][×] — единые размеры */
  .folder-sec { align-items: center; }
  .folder-sec-main { gap: 8px; min-width: 0; }
  .folder-sec-name { flex: 1; min-width: 0; }
  .folder-sec-count { margin-left: auto; }
  .folder-sec-del { width: 40px; height: 40px; font-size: 13px; }
}

/* --- панель дня: кнопка «+ Заметка» внизу, полная ширина, thumb-zone --- */
.day-panel-add {
  margin-top: var(--s3);
  min-height: 44px;
  flex: none;
}

/* --- поиск по настройкам --- */
.settings-search {
  margin-bottom: var(--s3);
}
.settings-search-clear {
  position: absolute;
  right: var(--s2);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--hint);
  cursor: pointer;
  font-size: 12px;
}@media (hover: hover) and (pointer: fine){
  .settings-search-clear:hover {
    background: var(--fill);
    color: var(--text);
  }
}
.settings-search-clear:active {
  background: var(--fill);
  color: var(--text);
}
.settings-search-input { padding-right: 36px; }
/* нативный ✕ у type=search дублирует наш — гасим (cancel + decoration) */
.settings-search-input::-webkit-search-cancel-button,
.settings-search-input::-webkit-search-decoration,
.settings-search-input::-webkit-search-results-button,
.settings-search-input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

/* --- Волна 2б: заголовок заметки auto-grow (textarea) --- */
.note-title-inline {
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 0;
  line-height: 1.25;
}

/* --- Волна 2б: маркер закрепления в карточке --- */
.note-pin-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.note-pin-flag svg { width: 12px; height: 12px; display: block; }/* --- Отступ списка снизу под постоянный таб-бар ------------------------ */
/* Линия --bottom-ui = высота бара (56px) + safe-area + 8px зазора. Тот же
   отступ получают архив/корзина (свой прокручиваемый .bin-view). */
@media (max-width: 600px){
  .bin-view {
    padding-bottom: calc(var(--bottom-ui) + var(--s4));
  }
}

/* ============ Нижний ряд drawer (эталон Obsidian Mobile 1.14.4, spec §8) ====
   Ряд из 5 действий 44px → пилюля-переключатель панели → имя хранилища
   со счётчиком «N файлов, M папок» и ⚙ в круге. Показывается ТОЛЬКО в
   drawer-оверлее (на экране списка те же действия живут в ☰-меню таб-бара),
   чтобы не дублировать нижнюю панель. */
.list-footer { display: none; }@media (max-width: 600px){.shell.drawer-open[data-drawer-section='boards'] .boards-list-pane .list-footer{
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    flex: none;
    padding: var(--s2) var(--s3) calc(var(--safe-area-inset-bottom) + var(--s2));
    border-top: 1px solid var(--separator);
    background: var(--surface);
  }/* Список сжимается, футер прижат к низу (flex-колонка панели). */
.shell.drawer-open .boards-list-pane .board-list{ min-height: 0; }

  .list-foot-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
  }
  .list-foot-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .list-foot-btn:active { background: var(--fill); }
  .list-foot-btn .icon { width: 20px; height: 20px; }

  .list-foot-switcher {
    display: flex;
    align-items: center;
    gap: var(--s2);
    width: 100%;
    min-height: 44px;
    padding: 0 var(--s3);
    border: 0;
    border-radius: var(--r-control);
    background: var(--fill);
    color: var(--text);
    font: inherit;
    font-size: var(--font-md);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }
  .list-foot-switcher .icon { width: 18px; height: 18px; flex: none; }
  .list-foot-switcher-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .list-foot-caret { transform: rotate(90deg); color: var(--hint); }
  .list-foot-switcher:active { background: var(--accent-soft); }

  .list-foot-vault {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s1) 0 0;
  }
  .list-foot-vault-text { flex: 1; min-width: 0; }
  .list-foot-vault-name { font-size: var(--font-md); font-weight: 700; }
  .list-foot-count {
    font-size: var(--font-xs);
    color: var(--hint);
    font-variant-numeric: tabular-nums;
  }
  .list-foot-gear {
    width: 44px;
    height: 44px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--fill);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .list-foot-gear .icon { width: 20px; height: 20px; }
  .list-foot-gear:active { background: var(--accent-soft); }
}
