.nm-sortable-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nm-sortable-card {
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

html.dark .nm-sortable-card {
  border-color: #334155;
  background: #0f172a;
}

.nm-sortable-row--drop-before,
.nm-sortable-row--drop-after {
  position: relative;
}

.nm-sortable-row--drop-before::after,
.nm-sortable-row--drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  box-sizing: border-box;
  background: transparent;
  pointer-events: none;
  z-index: 2;
}

.nm-sortable-row--drop-before::after {
  top: 0;
  border: 2px solid #2563eb;
  border-bottom: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.nm-sortable-row--drop-after::after {
  bottom: 0;
  border: 2px solid #2563eb;
  border-top: 0;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

/*
 * Writing outline append drops are semantically the same as dropping after
 * the last manuscript. Keep the empty-container cue, but when a container
 * already has manuscripts, render the same partial outline on its last row.
 */
.nm-writing-manuscript-list.nm-writing-drop-target:has(> [data-manuscript-id]) {
  background: transparent;
}

.nm-writing-manuscript-list.nm-writing-drop-target:has(> [data-manuscript-id])::after {
  content: none;
}

.nm-writing-manuscript-list.nm-writing-drop-target:has(> [data-manuscript-id])
  > [data-manuscript-id]:last-child:not(.nm-sortable-row--dragging)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  box-sizing: border-box;
  border: 2px solid #2563eb;
  border-top: 0;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  background: transparent;
  pointer-events: none;
  z-index: 2;
}

html.dark .nm-writing-manuscript-list.nm-writing-drop-target:has(> [data-manuscript-id])
  > [data-manuscript-id]:last-child:not(.nm-sortable-row--dragging)::after {
  border-color: #60a5fa;
}

.nm-sortable-row--dragging {
  position: relative;
  z-index: 20;
  opacity: .72;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12) !important;
  transform: none;
}

html.dark .nm-sortable-row--dragging {
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28) !important;
}

.nm-sortable-drag-handle {
  position: relative;
  display: inline-flex;
  align-self: stretch !important;
  min-width: 28px;
  height: auto !important;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  color: #94a3b8;
  cursor: grab;
  font-size: 0 !important;
  line-height: 0 !important;
  letter-spacing: 0 !important;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.nm-sortable-drag-handle::before {
  content: "";
  display: block;
  width: 2px;
  height: 2px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 -4px 0 currentColor,
    0 4px 0 currentColor,
    4px -4px 0 currentColor,
    4px 0 0 currentColor,
    4px 4px 0 currentColor;
  transform: translateX(-2px);
  pointer-events: none;
}

.nm-sortable-drag-handle:active { cursor: grabbing; }

@media (pointer: coarse) {
  .nm-sortable-drag-handle { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .nm-sortable-row--dragging { transform: none !important; }
}

/* Map list resume surface: keep the primary return action visible without displacing the map grid. */
[data-map-resume-surface] {
  background: #fff !important;
  border-color: #e2e8f0 !important;
}

html.dark [data-map-resume-surface] {
  background: #0f172a !important;
  border-color: #334155 !important;
}

@media (max-width: 639px) {
  [data-map-resume-surface] {
    margin-bottom: 12px !important;
    padding: 8px 10px !important;
  }

  [data-map-resume-surface] > div {
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
  }

  [data-map-resume-surface] > div > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
  }

  [data-map-resume-surface] > div > div > p:first-child {
    display: none;
  }

  [data-map-resume-surface] h2 {
    margin-top: 0 !important;
    font-size: 0.875rem !important;
    line-height: 1.25rem !important;
  }

  [data-map-resume-surface] h2 + div {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    margin-top: 2px !important;
    overflow: hidden;
    font-size: 0.625rem !important;
    line-height: 1rem !important;
    white-space: nowrap;
  }

  [data-map-resume-surface] h2 + div > span:nth-child(2),
  [data-map-resume-surface] h2 + div > span:nth-child(3) {
    display: none !important;
  }

  [data-map-resume-surface] .map-status-pill {
    height: 20px;
    max-width: 72px;
    padding: 0 6px;
    gap: 4px;
    font-size: 10px;
  }

  [data-map-resume-surface] a[data-analytics-cta="map_resume"] {
    min-height: 34px !important;
    width: auto !important;
    padding: 0 10px !important;
    font-size: 0.6875rem !important;
    line-height: 1 !important;
    white-space: nowrap;
  }
}

@media (min-width: 640px) {
  [data-map-resume-surface] {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  [data-map-resume-surface] > div {
    gap: 12px !important;
  }

  [data-map-resume-surface] > div > div > p:first-child {
    display: none;
  }

  [data-map-resume-surface] h2 {
    margin-top: 0 !important;
    font-size: 1rem !important;
    line-height: 1.5rem !important;
  }

  [data-map-resume-surface] h2 + div {
    margin-top: 4px !important;
    row-gap: 4px !important;
  }

  [data-map-resume-surface] .map-status-pill {
    height: 24px;
    padding: 0 8px;
  }
}

@media (min-width: 1024px) {
  [data-map-resume-surface] > div > div:first-child {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
  }

  [data-map-resume-surface] h2 {
    min-width: 0;
    flex: 0 1 40%;
  }

  [data-map-resume-surface] h2 + div {
    min-width: 0;
    flex: 0 1 auto;
    margin-top: 0 !important;
  }
}
