/* Notes-only control rhythm. Loaded after style.css and app-ui.css. */

/* The overview row is rendered as a native button by the Notes renderer. */
.notes-overview button.notes-list-item {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}

.notes-overview .notes-list-item-title,
.notes-overview .notes-list-item-preview {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

/* Keep the project-note and user-note toolbars on the same compact rhythm. */
.note-editor > .note-editor-toolbar,
.user-note-editor > .note-editor-toolbar {
  box-sizing: border-box;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 4px 0;
  overflow: visible;
}

.note-editor-toolbar .note-tb-btn {
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  height: 32px;
  border-color: transparent;
  border-radius: var(--r-sm, 4px);
  color: var(--text);
  transition: background-color var(--ui-motion, 160ms), border-color var(--ui-motion, 160ms), color var(--ui-motion, 160ms), opacity var(--ui-motion, 160ms);
  touch-action: manipulation;
}

.note-editor-toolbar .note-tb-btn:hover {
  border-color: var(--user-note-control-border);
  background: var(--overlay-active);
  color: var(--text-primary);
  opacity: 1;
}

.note-editor-toolbar .note-tb-btn--danger:hover {
  border-color: var(--error-faint);
  background: var(--error-faint);
  color: var(--error);
}

.note-editor-toolbar .note-tb-btn--caret {
  flex-basis: 32px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.note-editor-toolbar .note-tb-sep {
  flex: 0 0 1px;
  height: 16px;
  margin: 0 2px;
}

.note-editor-toolbar .un-tb-more-item {
  min-height: 32px;
  touch-action: manipulation;
}

/* Block tools remain tab-reachable while quiet, then appear on hover or focus. */
.note-editor .note-block-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ui-motion, 160ms) var(--ease, ease-out);
}

.note-editor .note-block:hover .note-block-actions,
.note-editor .note-block:focus-within .note-block-actions {
  opacity: 1;
  pointer-events: auto;
}

.note-editor .note-block-btn {
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--user-note-control-border);
  border-radius: var(--r-sm, 4px);
  background: var(--overlay-active);
  color: var(--muted);
  touch-action: manipulation;
}

.note-editor .note-block-btn:hover {
  color: var(--text);
}

.note-editor .note-block-btn-del:hover,
.note-editor .note-img-remove:hover,
.note-editor .note-check-remove:hover {
  color: var(--error);
}

.note-editor .note-check-row:focus-within .note-check-remove,
.note-editor .note-check-row:hover .note-check-remove {
  opacity: 1;
  pointer-events: auto;
}

.note-editor .note-check-remove {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--r-sm, 4px);
  touch-action: manipulation;
}

.note-editor .note-check-box {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.note-editor label.note-check-control {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  cursor: pointer;
  touch-action: manipulation;
}

.note-editor .note-check-add {
  box-sizing: border-box;
  width: 100%;
  min-height: 32px;
}

.note-editor .note-img-remove {
  box-sizing: border-box;
  min-height: 32px;
  padding: 4px 10px;
  touch-action: manipulation;
}

.note-editor .note-img-drop {
  touch-action: manipulation;
}

.note-editor .note-chip-tag {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.note-editor .note-chip-remove {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--r-sm, 4px);
  touch-action: manipulation;
}

.user-note-editor .un-chrome-bar .note-editor-title {
  box-sizing: border-box;
  min-height: 32px;
}

.user-note-editor .un-chrome-bar .note-tb-btn {
  box-sizing: border-box;
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  height: 32px;
}

.user-note-editor .un-chrome-bar .note-tb-btn--label {
  width: auto;
}

.user-note-editor .user-note-tag .remove-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
}

/* Match the app's phone and touch-tablet breakpoint. The width arm also covers
   mobile Chromium configurations that expose a fine primary pointer. */
@media (max-width: 768px), (max-width: 1024px) and (pointer: coarse) {
  .note-editor-toolbar .note-tb-btn,
  .note-editor-toolbar .note-tb-btn--caret {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0 8px;
  }

  .note-editor-toolbar .note-tb-btn--icon,
  .note-editor-toolbar .note-tb-btn--caret {
    padding: 0;
  }

  .note-editor-toolbar .note-tb-btn--label {
    flex-basis: auto;
    width: auto;
    min-width: 44px;
    padding: 0 10px;
  }

  .note-editor-toolbar .note-tb-sep {
    display: none;
  }

  .note-editor-toolbar .un-tb-more-item {
    min-height: 44px;
    padding-block: 10px;
  }

  .note-editor-toolbar .un-tb-more-wrap:not(.un-tb-split) .un-tb-more-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
  }

  .note-editor .note-block-actions {
    position: static;
    display: flex;
    width: max-content;
    max-width: 100%;
    margin: 0 0 4px auto;
    opacity: 1;
    pointer-events: auto;
  }

  .note-editor .note-block-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .note-editor .note-check-row {
    min-height: 44px;
    padding: 0 4px;
  }

  .note-editor .note-check-remove {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    opacity: 0.72;
    pointer-events: auto;
  }

  .note-editor .note-check-box {
    width: 20px;
    min-width: 20px;
    height: 20px;
    min-height: 20px;
    touch-action: manipulation;
  }

  .note-editor label.note-check-control {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .note-editor .note-check-add,
  .note-editor .note-img-remove,
  .note-editor .note-chip-remove {
    min-height: 44px;
  }

  .note-editor .note-chip-remove {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .user-note-editor .un-chrome-bar .note-editor-title,
  .user-note-editor .user-note-tag .remove-tag {
    min-height: 44px;
  }

  .user-note-editor .un-chrome-bar .note-tb-btn {
    flex-basis: 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
  }

  .user-note-editor .un-chrome-bar .note-tb-btn--label {
    flex-basis: auto;
    width: auto;
    min-width: 44px;
    padding: 0 10px;
  }

  .user-note-editor .user-note-tag .remove-tag {
    min-width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note-editor .note-block-actions,
  .note-editor-toolbar .note-tb-btn {
    transition: none;
  }
}
