/* Entity notes popover — Vanilla Noir, crisp, readable */

.notes-mounts {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.notes-ui {
  position: relative;
  min-width: 0;
}

.notes-ui__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

.notes-ui__label {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.notes-ui__trigger {
  flex-shrink: 0;
  min-height: 36px;
  padding-inline: 14px;
  font-size: 13px;
  font-weight: 560;
  color: var(--text) !important;
  background: var(--surface-3) !important;
  border: 1px solid var(--border-strong) !important;
  transition:
    background 180ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 180ms cubic-bezier(0.22, 1, 0.36, 1),
    color 180ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.notes-ui__trigger:hover {
  color: var(--text-warm) !important;
  background: var(--surface-hover) !important;
  border-color: var(--accent-border) !important;
}

.notes-ui__trigger--filled {
  color: var(--text-warm) !important;
  background: var(--surface-3) !important;
  border-color: var(--accent) !important;
  box-shadow: inset 0 0 0 1px rgba(243, 233, 210, 0.18);
}

.notes-ui__trigger--filled:hover {
  color: var(--bg) !important;
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}

.notes-ui__trigger[aria-expanded="true"] {
  color: var(--bg) !important;
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}

.notes-ui__panel {
  position: fixed;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: min(420px, 52vh);
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-4);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  pointer-events: none;
  transition:
    opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Fixed / portaled panel escapes drawer and overflow clipping */
.notes-ui__panel--fixed {
  position: fixed;
  z-index: 90;
  right: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notes-ui__panel--fixed[data-placement="top"] {
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
}

.notes-ui__panel--fixed[data-placement="top"].is-open {
  transform: translateY(0) scale(1);
}

.notes-ui__panel[hidden] {
  display: none !important;
}

.notes-ui__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.notes-ui__panel-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.notes-ui__panel-title {
  margin: 0;
  min-width: 0;
  color: var(--text-warm);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.notes-ui__close {
  flex-shrink: 0;
}

.notes-ui__list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.notes-ui__list--empty {
  align-items: center;
  justify-content: center;
  min-height: 48px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.notes-ui__item {
  min-width: 0;
  padding: var(--space-3);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  opacity: 0;
  transform: translateY(6px);
}

.notes-ui__panel.is-open .notes-ui__item {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: calc(40ms + (var(--note-i, 0) * 35ms));
}

.notes-ui__item-body {
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-ui__item-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.notes-ui__item-meta span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.notes-ui__delete {
  flex-shrink: 0;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.notes-ui__composer {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.notes-ui__composer .field {
  min-width: 0;
  color: var(--text-secondary);
}

.notes-ui__composer textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  color: var(--text) !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-control);
  box-shadow: none !important;
  outline: none !important;
  resize: vertical;
  font-size: 13px;
  line-height: 1.45;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.notes-ui__composer textarea::placeholder {
  color: var(--text-secondary) !important;
  opacity: 1;
}

.notes-ui__composer textarea:hover {
  border-color: var(--border-strong) !important;
}

.notes-ui__composer textarea:focus,
.notes-ui__composer textarea:focus-visible {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(243, 233, 210, 0.14) !important;
  outline: none !important;
}

.notes-ui__actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  min-width: 0;
}

.notes-ui__phi {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.notes-ui__status {
  min-width: 0;
  font-size: 12px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.notes-ui__status--error {
  color: var(--critical, #e8a0a0);
}

@media (max-width: 520px) {
  .notes-ui__panel--fixed {
    max-width: calc(100vw - 16px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notes-ui__trigger,
  .notes-ui__panel,
  .notes-ui__item,
  .notes-ui__composer textarea {
    transition: none !important;
  }

  .notes-ui__panel,
  .notes-ui__item {
    transform: none !important;
    opacity: 1 !important;
  }
}
